comparison roundup/hyperdb.py @ 477:05a46da7293a

hyperdb docstrings
author Richard Jones <richard@users.sourceforge.net>
date Wed, 02 Jan 2002 04:18:17 +0000
parents a1a44636bace
children 59e87f7b7916 c242455d9b46
comparison
equal deleted inserted replaced
476:00450ff9c4e7 477:05a46da7293a
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: hyperdb.py,v 1.44 2002-01-02 02:31:38 richard Exp $ 18 # $Id: hyperdb.py,v 1.45 2002-01-02 04:18:17 richard Exp $
19 19
20 __doc__ = """ 20 __doc__ = """
21 Hyperdatabase implementation, especially field types. 21 Hyperdatabase implementation, especially field types.
22 """ 22 """
23 23
74 74
75 # 75 #
76 # the base Database class 76 # the base Database class
77 # 77 #
78 class Database: 78 class Database:
79 '''A database for storing records containing flexible data types.
80
81 This class defines a hyperdatabase storage layer, which the Classes use to
82 store their data.
83
84
85 Transactions
86 ------------
87 The Database should support transactions through the commit() and
88 rollback() methods. All other Database methods should be transaction-aware,
89 using data from the current transaction before looking up the database.
90
91 An implementation must provide an override for the get() method so that the
92 in-database value is returned in preference to the in-transaction value.
93 This is necessary to determine if any values have changed during a
94 transaction.
95
96 '''
97
79 # flag to set on retired entries 98 # flag to set on retired entries
80 RETIRED_FLAG = '__hyperdb_retired' 99 RETIRED_FLAG = '__hyperdb_retired'
81 100
101 def __init__(self, storagelocator, journaltag=None):
102 """Open a hyperdatabase given a specifier to some storage.
103
104 The meaning of 'storagelocator' depends on the particular
105 implementation of the hyperdatabase. It could be a file name,
106 a directory path, a socket descriptor for a connection to a
107 database over the network, etc.
108
109 The 'journaltag' is a token that will be attached to the journal
110 entries for any edits done on the database. If 'journaltag' is
111 None, the database is opened in read-only mode: the Class.create(),
112 Class.set(), and Class.retire() methods are disabled.
113 """
114 raise NotImplementedError
115
116 def __getattr__(self, classname):
117 """A convenient way of calling self.getclass(classname)."""
118 raise NotImplementedError
119
120 def addclass(self, cl):
121 '''Add a Class to the hyperdatabase.
122 '''
123 raise NotImplementedError
124
125 def getclasses(self):
126 """Return a list of the names of all existing classes."""
127 raise NotImplementedError
128
129 def getclass(self, classname):
130 """Get the Class object representing a particular class.
131
132 If 'classname' is not a valid class name, a KeyError is raised.
133 """
134 raise NotImplementedError
135
136 def clear(self):
137 '''Delete all database contents.
138 '''
139 raise NotImplementedError
140
141 def getclassdb(self, classname, mode='r'):
142 '''Obtain a connection to the class db that will be used for
143 multiple actions.
144 '''
145 raise NotImplementedError
146
147 def addnode(self, classname, nodeid, node):
148 '''Add the specified node to its class's db.
149 '''
150 raise NotImplementedError
151
152 def setnode(self, classname, nodeid, node):
153 '''Change the specified node.
154 '''
155 raise NotImplementedError
156
157 def getnode(self, classname, nodeid, db=None, cache=1):
158 '''Get a node from the database.
159 '''
160 raise NotImplementedError
161
162 def hasnode(self, classname, nodeid, db=None):
163 '''Determine if the database has a given node.
164 '''
165 raise NotImplementedError
166
167 def countnodes(self, classname, db=None):
168 '''Count the number of nodes that exist for a particular Class.
169 '''
170 raise NotImplementedError
171
172 def getnodeids(self, classname, db=None):
173 '''Retrieve all the ids of the nodes for a particular Class.
174 '''
175 raise NotImplementedError
176
177 def storefile(self, classname, nodeid, property, content):
178 '''Store the content of the file in the database.
179
180 The property may be None, in which case the filename does not
181 indicate which property is being saved.
182 '''
183 raise NotImplementedError
184
185 def getfile(self, classname, nodeid, property):
186 '''Store the content of the file in the database.
187 '''
188 raise NotImplementedError
189
190 def addjournal(self, classname, nodeid, action, params):
191 ''' Journal the Action
192 'action' may be:
193
194 'create' or 'set' -- 'params' is a dictionary of property values
195 'link' or 'unlink' -- 'params' is (classname, nodeid, propname)
196 'retire' -- 'params' is None
197 '''
198 raise NotImplementedError
199
200 def getjournal(self, classname, nodeid):
201 ''' get the journal for id
202 '''
203 raise NotImplementedError
204
205 def commit(self):
206 ''' Commit the current transactions.
207
208 Save all data changed since the database was opened or since the
209 last commit() or rollback().
210 '''
211 raise NotImplementedError
212
213 def rollback(self):
214 ''' Reverse all actions from the current transaction.
215
216 Undo all the changes made since the database was opened or the last
217 commit() or rollback() was performed.
218 '''
219 raise NotImplementedError
82 220
83 _marker = [] 221 _marker = []
84 # 222 #
85 # The base Class class 223 # The base Class class
86 # 224 #
887 cl.create(name=option[i], order=i) 1025 cl.create(name=option[i], order=i)
888 return hyperdb.Link(name) 1026 return hyperdb.Link(name)
889 1027
890 # 1028 #
891 # $Log: not supported by cvs2svn $ 1029 # $Log: not supported by cvs2svn $
1030 # Revision 1.44 2002/01/02 02:31:38 richard
1031 # Sorry for the huge checkin message - I was only intending to implement #496356
1032 # but I found a number of places where things had been broken by transactions:
1033 # . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
1034 # for _all_ roundup-generated smtp messages to be sent to.
1035 # . the transaction cache had broken the roundupdb.Class set() reactors
1036 # . newly-created author users in the mailgw weren't being committed to the db
1037 #
1038 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
1039 # on when I found that stuff :):
1040 # . #496356 ] Use threading in messages
1041 # . detectors were being registered multiple times
1042 # . added tests for mailgw
1043 # . much better attaching of erroneous messages in the mail gateway
1044 #
892 # Revision 1.43 2001/12/20 06:13:24 rochecompaan 1045 # Revision 1.43 2001/12/20 06:13:24 rochecompaan
893 # Bugs fixed: 1046 # Bugs fixed:
894 # . Exception handling in hyperdb for strings-that-look-like numbers got 1047 # . Exception handling in hyperdb for strings-that-look-like numbers got
895 # lost somewhere 1048 # lost somewhere
896 # . Internet Explorer submits full path for filename - we now strip away 1049 # . Internet Explorer submits full path for filename - we now strip away

Roundup Issue Tracker: http://roundup-tracker.org/