Mercurial > p > roundup > code
comparison roundup/hyperdb.py @ 430:350685601f37
Database transactions.
. We now have basic transaction support! Information is only written to
the database when the commit() method is called. Only the anydbm
backend is modified in this way - neither of the bsddb backends have been.
The mail, admin and cgi interfaces all use commit (except the admin tool
doesn't have a commit command, so interactive users can't commit...)
. Fixed login/registration forwarding the user to the right page (or not,
on a failure)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sat, 01 Dec 2001 07:17:50 +0000 |
| parents | 831e91e23963 |
| children | a28a80b714f9 |
comparison
equal
deleted
inserted
replaced
| 429:fbfca7448422 | 430:350685601f37 |
|---|---|
| 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.37 2001-11-28 21:55:35 richard Exp $ | 18 # $Id: hyperdb.py,v 1.38 2001-12-01 07:17:50 richard Exp $ |
| 19 | 19 |
| 20 __doc__ = """ | 20 __doc__ = """ |
| 21 Hyperdatabase implementation, especially field types. | 21 Hyperdatabase implementation, especially field types. |
| 22 """ | 22 """ |
| 23 | 23 |
| 242 | 242 |
| 243 'nodeid' must be the id of an existing node of this class or an | 243 'nodeid' must be the id of an existing node of this class or an |
| 244 IndexError is raised. 'propname' must be the name of a property | 244 IndexError is raised. 'propname' must be the name of a property |
| 245 of this class or a KeyError is raised. | 245 of this class or a KeyError is raised. |
| 246 """ | 246 """ |
| 247 d = self.db.getnode(self.classname, nodeid) | |
| 248 | |
| 249 # convert the marshalled data to instances | |
| 250 for key, prop in self.properties.items(): | |
| 251 if isinstance(prop, Date): | |
| 252 d[key] = date.Date(d[key]) | |
| 253 elif isinstance(prop, Interval): | |
| 254 d[key] = date.Interval(d[key]) | |
| 255 elif isinstance(prop, Password): | |
| 256 p = password.Password() | |
| 257 p.unpack(d[key]) | |
| 258 d[key] = p | |
| 259 | |
| 260 if propname == 'id': | 247 if propname == 'id': |
| 261 return nodeid | 248 return nodeid |
| 249 | |
| 250 # get the node's dict | |
| 251 d = self.db.getnode(self.classname, nodeid) | |
| 262 if not d.has_key(propname) and default is not _marker: | 252 if not d.has_key(propname) and default is not _marker: |
| 263 return default | 253 return default |
| 254 | |
| 255 # get the value | |
| 256 prop = self.properties[propname] | |
| 257 | |
| 258 # possibly convert the marshalled data to instances | |
| 259 if isinstance(prop, Date): | |
| 260 return date.Date(d[propname]) | |
| 261 elif isinstance(prop, Interval): | |
| 262 return date.Interval(d[propname]) | |
| 263 elif isinstance(prop, Password): | |
| 264 p = password.Password() | |
| 265 p.unpack(d[propname]) | |
| 266 return p | |
| 267 | |
| 264 return d[propname] | 268 return d[propname] |
| 265 | 269 |
| 266 # XXX not in spec | 270 # XXX not in spec |
| 267 def getnode(self, nodeid): | 271 def getnode(self, nodeid): |
| 268 ''' Return a convenience wrapper for the node | 272 ''' Return a convenience wrapper for the node |
| 867 cl.create(name=option[i], order=i) | 871 cl.create(name=option[i], order=i) |
| 868 return hyperdb.Link(name) | 872 return hyperdb.Link(name) |
| 869 | 873 |
| 870 # | 874 # |
| 871 # $Log: not supported by cvs2svn $ | 875 # $Log: not supported by cvs2svn $ |
| 876 # Revision 1.37 2001/11/28 21:55:35 richard | |
| 877 # . login_action and newuser_action return values were being ignored | |
| 878 # . Woohoo! Found that bloody re-login bug that was killing the mail | |
| 879 # gateway. | |
| 880 # (also a minor cleanup in hyperdb) | |
| 881 # | |
| 872 # Revision 1.36 2001/11/27 03:16:09 richard | 882 # Revision 1.36 2001/11/27 03:16:09 richard |
| 873 # Another place that wasn't handling missing properties. | 883 # Another place that wasn't handling missing properties. |
| 874 # | 884 # |
| 875 # Revision 1.35 2001/11/22 15:46:42 jhermann | 885 # Revision 1.35 2001/11/22 15:46:42 jhermann |
| 876 # Added module docstrings to all modules. | 886 # Added module docstrings to all modules. |
