Skip to content

Commit 3b74db8

Browse files
author
Richard Jones
committed
Added the fabricated property "id".
1 parent 6339b83 commit 3b74db8

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

roundup/hyperdb.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: hyperdb.py,v 1.4 2001-07-27 06:25:35 richard Exp $
1+
# $Id: hyperdb.py,v 1.5 2001-07-29 04:05:37 richard Exp $
22

33
# standard python modules
44
import cPickle, re, string
@@ -98,8 +98,13 @@ def create(self, **propvalues):
9898
If an id in a link or multilink property does not refer to a valid
9999
node, an IndexError is raised.
100100
"""
101+
if propvalues.has_key('id'):
102+
raise KeyError, '"id" is reserved'
103+
101104
if self.db.journaltag is None:
102105
raise DatabaseError, 'Database open read-only'
106+
107+
# new node's id
103108
newid = str(self.count() + 1)
104109

105110
# validate propvalues
@@ -194,6 +199,8 @@ def get(self, nodeid, propname):
194199
IndexError is raised. 'propname' must be the name of a property
195200
of this class or a KeyError is raised.
196201
"""
202+
if propname == 'id':
203+
return nodeid
197204
# nodeid = str(nodeid)
198205
d = self.db.getnode(self.classname, nodeid)
199206
return d[propname]
@@ -224,8 +231,13 @@ class or a KeyError is raised.
224231
"""
225232
if not propvalues:
226233
return
234+
235+
if propvalues.has_key('id'):
236+
raise KeyError, '"id" is reserved'
237+
227238
if self.db.journaltag is None:
228239
raise DatabaseError, 'Database open read-only'
240+
229241
# nodeid = str(nodeid)
230242
node = self.db.getnode(self.classname, nodeid)
231243
if node.has_key(self.db.RETIRED_FLAG):
@@ -696,7 +708,9 @@ def count(self):
696708

697709
def getprops(self):
698710
"""Return a dictionary mapping property names to property objects."""
699-
return self.properties
711+
d = self.properties.copy()
712+
d['id'] = String()
713+
return d
700714

701715
def addprop(self, **properties):
702716
"""Add properties to this class.
@@ -753,6 +767,11 @@ def Choice(name, *options):
753767

754768
#
755769
# $Log: not supported by cvs2svn $
770+
# Revision 1.4 2001/07/27 06:25:35 richard
771+
# Fixed some of the exceptions so they're the right type.
772+
# Removed the str()-ification of node ids so we don't mask oopsy errors any
773+
# more.
774+
#
756775
# Revision 1.3 2001/07/27 05:17:14 richard
757776
# just some comments
758777
#

roundup/roundupdb.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: roundupdb.py,v 1.3 2001-07-23 07:14:41 richard Exp $
1+
# $Id: roundupdb.py,v 1.4 2001-07-29 04:05:37 richard Exp $
22

33
import re, os, smtplib, socket
44

@@ -107,8 +107,9 @@ def getprops(self):
107107
d['creator'] = hyperdb.Link("user")
108108
return d
109109

110-
# New methods:
111-
110+
#
111+
# Detector interface
112+
#
112113
def audit(self, event, detector):
113114
"""Register a detector
114115
"""
@@ -119,6 +120,7 @@ def react(self, event, detector):
119120
"""
120121
self.reactors[event].append(detector)
121122

123+
122124
class FileClass(Class):
123125
def create(self, **propvalues):
124126
''' snaffle the file propvalue and store in a file
@@ -245,6 +247,9 @@ def sendmessage(self, nodeid, msgid):
245247

246248
#
247249
# $Log: not supported by cvs2svn $
250+
# Revision 1.3 2001/07/23 07:14:41 richard
251+
# Moved the database backends off into backends.
252+
#
248253
# Revision 1.2 2001/07/22 12:09:32 richard
249254
# Final commit of Grande Splite
250255
#

0 commit comments

Comments
 (0)