Skip to content

Commit 9ffe88b

Browse files
author
Richard Jones
committed
This is my attempt to include the "actor" property in the metakit backend...
...though I'm not at all confident that migration is handled. I'll try to test this out though (I'll be doing that with *all* the backends before 0.7 goes out ;)
1 parent 006116c commit 9ffe88b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

roundup/backends/back_metakit.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.63 2004-03-19 04:47:59 richard Exp $
1+
# $Id: back_metakit.py,v 1.64 2004-03-19 04:58:52 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -352,7 +352,7 @@ class Class(hyperdb.Class):
352352
privateprops = None
353353
def __init__(self, db, classname, **properties):
354354
if (properties.has_key('creation') or properties.has_key('activity')
355-
or properties.has_key('creator')):
355+
or properties.has_key('creator') or properties.has_key('actor')):
356356
raise ValueError, '"creation", "activity" and "creator" are '\
357357
'reserved'
358358
if hasattr(db, classname):
@@ -364,6 +364,7 @@ def __init__(self, db, classname, **properties):
364364
self.ruprops = properties
365365
self.privateprops = { 'id' : hyperdb.String(),
366366
'activity' : hyperdb.Date(),
367+
'actor' : hyperdb.Link('user'),
367368
'creation' : hyperdb.Date(),
368369
'creator' : hyperdb.Link('user') }
369370

@@ -765,6 +766,8 @@ class or a KeyError is raised.
765766
return propvalues
766767
if not propvalues.has_key('activity'):
767768
row.activity = int(time.time())
769+
if not propvalues.has_key('actor'):
770+
row.actor = int(self.db.getuid())
768771
if isnew:
769772
if not row.creation:
770773
row.creation = int(time.time())
@@ -1583,8 +1586,11 @@ def __getview(self):
15831586
if _typmap[rutyp.__class__] != mkprop.type:
15841587
break
15851588
else:
1586-
1587-
return view.ordered(1)
1589+
# make sure we have the 'actor' property too
1590+
for mkprop in mkprops:
1591+
if mkprop.name == 'actor':
1592+
return view.ordered(1)
1593+
15881594
# The schema has changed. We need to create or restructure the mk view
15891595
# id comes first, so we can use view.ordered(1) so that
15901596
# MK will order it for us to allow binary-search quick lookups on
@@ -1593,7 +1599,8 @@ def __getview(self):
15931599
s = ["%s[id:I" % self.classname]
15941600

15951601
# these columns will always be added, we can't trample them :)
1596-
_columns = {"id":"I", "_isdel":"I", "activity":"I", "creation":"I", "creator":"I"}
1602+
_columns = {"id":"I", "_isdel":"I", "activity":"I", "actor": "I",
1603+
"creation":"I", "creator":"I"}
15971604

15981605
for nm, rutyp in self.ruprops.items():
15991606
mktyp = _typmap[rutyp.__class__].upper()
@@ -1607,7 +1614,7 @@ def __getview(self):
16071614

16081615
# XXX FIX ME -> in some tests, creation:I becomes creation:S is this
16091616
# okay? Does this need to be supported?
1610-
s.append('_isdel:I,activity:I,creation:I,creator:I]')
1617+
s.append('_isdel:I,activity:I,actor:I,creation:I,creator:I]')
16111618
view = self.db._db.getas(','.join(s))
16121619
self.db.commit()
16131620
return view.ordered(1)

0 commit comments

Comments
 (0)