comparison roundup/hyperdb.py @ 719:fed4c363a7f3

node caching now works, and gives a small boost in performance As a part of this, I cleaned up the DEBUG output and implemented TRACE output (HYPERDBTRACE='file to trace to') with checkpoints at the start of CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff (using if __debug__ which is compiled out with -O)
author Richard Jones <richard@users.sourceforge.net>
date Wed, 15 May 2002 06:21:21 +0000
parents 509a101305da
children b0d887310f7a
comparison
equal deleted inserted replaced
718:e10c37f53efd 719:fed4c363a7f3
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.63 2002-04-15 23:25:15 richard Exp $ 18 # $Id: hyperdb.py,v 1.64 2002-05-15 06:21:21 richard Exp $
19 19
20 __doc__ = """ 20 __doc__ = """
21 Hyperdatabase implementation, especially field types. 21 Hyperdatabase implementation, especially field types.
22 """ 22 """
23 23
24 # standard python modules 24 # standard python modules
25 import re, string, weakref, os 25 import re, string, weakref, os, time
26 26
27 # roundup modules 27 # roundup modules
28 import date, password 28 import date, password
29 29
30 # configure up the DEBUG and TRACE captures
31 class Sink:
32 def write(self, content):
33 pass
30 DEBUG = os.environ.get('HYPERDBDEBUG', '') 34 DEBUG = os.environ.get('HYPERDBDEBUG', '')
35 if DEBUG and __debug__:
36 DEBUG = open(DEBUG, 'a')
37 else:
38 DEBUG = Sink()
39 TRACE = os.environ.get('HYPERDBTRACE', '')
40 if TRACE and __debug__:
41 TRACE = open(TRACE, 'w')
42 else:
43 TRACE = Sink()
44 def traceMark():
45 print >>TRACE, '**MARK', time.ctime()
46 del Sink
31 47
32 # 48 #
33 # Types 49 # Types
34 # 50 #
35 class String: 51 class String:
173 189
174 def serialise(self, classname, node): 190 def serialise(self, classname, node):
175 '''Copy the node contents, converting non-marshallable data into 191 '''Copy the node contents, converting non-marshallable data into
176 marshallable data. 192 marshallable data.
177 ''' 193 '''
178 if DEBUG: print 'serialise', classname, node 194 if __debug__:
195 print >>DEBUG, 'serialise', classname, node
179 properties = self.getclass(classname).getprops() 196 properties = self.getclass(classname).getprops()
180 d = {} 197 d = {}
181 for k, v in node.items(): 198 for k, v in node.items():
182 # if the property doesn't exist, or is the "retired" flag then 199 # if the property doesn't exist, or is the "retired" flag then
183 # it won't be in the properties dict 200 # it won't be in the properties dict
204 raise NotImplementedError 221 raise NotImplementedError
205 222
206 def unserialise(self, classname, node): 223 def unserialise(self, classname, node):
207 '''Decode the marshalled node data 224 '''Decode the marshalled node data
208 ''' 225 '''
209 if DEBUG: print 'unserialise', classname, node 226 if __debug__:
227 print >>DEBUG, 'unserialise', classname, node
210 properties = self.getclass(classname).getprops() 228 properties = self.getclass(classname).getprops()
211 d = {} 229 d = {}
212 for k, v in node.items(): 230 for k, v in node.items():
213 # if the property doesn't exist, or is the "retired" flag then 231 # if the property doesn't exist, or is the "retired" flag then
214 # it won't be in the properties dict 232 # it won't be in the properties dict
1125 cl.create(name=options[i], order=i) 1143 cl.create(name=options[i], order=i)
1126 return hyperdb.Link(name) 1144 return hyperdb.Link(name)
1127 1145
1128 # 1146 #
1129 # $Log: not supported by cvs2svn $ 1147 # $Log: not supported by cvs2svn $
1148 # Revision 1.63 2002/04/15 23:25:15 richard
1149 # . node ids are now generated from a lockable store - no more race conditions
1150 #
1151 # We're using the portalocker code by Jonathan Feinberg that was contributed
1152 # to the ASPN Python cookbook. This gives us locking across Unix and Windows.
1153 #
1130 # Revision 1.62 2002/04/03 07:05:50 richard 1154 # Revision 1.62 2002/04/03 07:05:50 richard
1131 # d'oh! killed retirement of nodes :( 1155 # d'oh! killed retirement of nodes :(
1132 # all better now... 1156 # all better now...
1133 # 1157 #
1134 # Revision 1.61 2002/04/03 06:11:51 richard 1158 # Revision 1.61 2002/04/03 06:11:51 richard

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