Crossfire Server, Trunk
CFDataBase.py
Go to the documentation of this file.
1
# CFBank.py - CFBank class
2
#
3
# Copyright (C) 2002 Joris Bontje
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
#
19
# The author can be reached via e-mail at jbontje@suespammers.org
20
#
21
#Updated to use new path functions in CFPython -Todd Mitchell
22
#Duplicated from CFBank.py and modified to store arbitrary python objects - Alestan 2010
23
24
import
os.path
25
import
shelve
26
27
import
Crossfire
28
29
class
CFDataBase
:
30
bankdb = {}
31
32
def
__init__
(self, bankfile):
33
self.
bankdb_file
= os.path.join(Crossfire.LocalDirectory(), bankfile)
34
self.
bankdb
= shelve.open(self.
bankdb_file
, writeback=
True
)
35
36
def
store
(self, name, value):
37
38
self.
bankdb
[name]=value
39
40
self.
bankdb
.sync()
41
42
return
1
43
44
def
get
(self, name, default = 0):
45
return
self.
bankdb
.
get
(name, default)
46
47
def
remove_record
(self,name):
48
if
name
in
self.
bankdb
:
49
del self.
bankdb
[name]
50
Crossfire.Log(Crossfire.LogDebug,
"%s CFDataBase record removed."
%name)
51
self.
bankdb
.sync()
52
return
1
53
else
:
54
return
0
CFDataBase.CFDataBase.get
def get(self, name, default=0)
Definition:
CFDataBase.py:44
CFDataBase.CFDataBase.__init__
def __init__(self, bankfile)
Definition:
CFDataBase.py:32
CFDataBase.CFDataBase.remove_record
def remove_record(self, name)
Definition:
CFDataBase.py:47
CFDataBase.CFDataBase.store
def store(self, name, value)
Definition:
CFDataBase.py:36
CFDataBase.CFDataBase.bankdb_file
bankdb_file
Definition:
CFDataBase.py:33
CFDataBase.CFDataBase
Definition:
CFDataBase.py:29
CFDataBase.CFDataBase.bankdb
dictionary bankdb
Definition:
CFDataBase.py:30
crossfire-crossfire-maps
python
CFDataBase.py
Generated by
1.8.17