From b21ba30ed36f85a304c483a89e6bf24366f9c2d7 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 29 Jul 2001 04:05:37 +0000 Subject: [PATCH] Added the fabricated property "id". git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@124 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/hyperdb.py | 23 +++++++++++++++++++++-- roundup/roundupdb.py | 11 ++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 62f25b7..4c13318 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -1,4 +1,4 @@ -# $Id: hyperdb.py,v 1.4 2001-07-27 06:25:35 richard Exp $ +# $Id: hyperdb.py,v 1.5 2001-07-29 04:05:37 richard Exp $ # standard python modules import cPickle, re, string @@ -98,8 +98,13 @@ class Class: If an id in a link or multilink property does not refer to a valid node, an IndexError is raised. """ + if propvalues.has_key('id'): + raise KeyError, '"id" is reserved' + if self.db.journaltag is None: raise DatabaseError, 'Database open read-only' + + # new node's id newid = str(self.count() + 1) # validate propvalues @@ -194,6 +199,8 @@ class Class: IndexError is raised. 'propname' must be the name of a property of this class or a KeyError is raised. """ + if propname == 'id': + return nodeid # nodeid = str(nodeid) d = self.db.getnode(self.classname, nodeid) return d[propname] @@ -224,8 +231,13 @@ class Class: """ if not propvalues: return + + if propvalues.has_key('id'): + raise KeyError, '"id" is reserved' + if self.db.journaltag is None: raise DatabaseError, 'Database open read-only' + # nodeid = str(nodeid) node = self.db.getnode(self.classname, nodeid) if node.has_key(self.db.RETIRED_FLAG): @@ -696,7 +708,9 @@ class Class: def getprops(self): """Return a dictionary mapping property names to property objects.""" - return self.properties + d = self.properties.copy() + d['id'] = String() + return d def addprop(self, **properties): """Add properties to this class. @@ -753,6 +767,11 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.4 2001/07/27 06:25:35 richard +# Fixed some of the exceptions so they're the right type. +# Removed the str()-ification of node ids so we don't mask oopsy errors any +# more. +# # Revision 1.3 2001/07/27 05:17:14 richard # just some comments # diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index 25ebc63..51cd1db 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -1,4 +1,4 @@ -# $Id: roundupdb.py,v 1.3 2001-07-23 07:14:41 richard Exp $ +# $Id: roundupdb.py,v 1.4 2001-07-29 04:05:37 richard Exp $ import re, os, smtplib, socket @@ -107,8 +107,9 @@ class Class(hyperdb.Class): d['creator'] = hyperdb.Link("user") return d - # New methods: - + # + # Detector interface + # def audit(self, event, detector): """Register a detector """ @@ -119,6 +120,7 @@ class Class(hyperdb.Class): """ self.reactors[event].append(detector) + class FileClass(Class): def create(self, **propvalues): ''' snaffle the file propvalue and store in a file @@ -245,6 +247,9 @@ class IssueClass(Class): # # $Log: not supported by cvs2svn $ +# Revision 1.3 2001/07/23 07:14:41 richard +# Moved the database backends off into backends. +# # Revision 1.2 2001/07/22 12:09:32 richard # Final commit of Grande Splite # -- 2.30.2