index 4ea2a2dcdccdc5ad160733de44e8b47b9289327b..233de403cb6d1117e89834ea82e8daa3db14b3aa 100644 (file)
description="User is allowed to edit "+cn)
self.security.addPermission(name="View", klass=cn,
description="User is allowed to access "+cn)
+ self.security.addPermission(name="Retire", klass=cn,
+ description="User is allowed to retire "+cn)
def getclasses(self):
"""Return a list of the names of all existing classes."""
elif isinstance(prop, hyperdb.Interval) and v is not None:
d[k] = date.Interval(v)
elif isinstance(prop, hyperdb.Password) and v is not None:
- p = password.Password()
- p.unpack(v)
- d[k] = p
+ d[k] = password.Password(encrypted=v)
else:
d[k] = v
return d
self.transactions.append((self.doSetJournal, (classname, nodeid,
journal)))
+ def fix_journal(self, classname, journal):
+ """ fix password entries to correct type """
+ pwprops = {}
+ for pn, prop in self.getclass(classname).properties.iteritems():
+ if isinstance(prop, hyperdb.Password):
+ pwprops [pn] = 1
+ if not pwprops:
+ return journal
+ for j in journal:
+ if j[3] == 'set':
+ for k, v in j[4].items():
+ if k in pwprops:
+ j[4][k] = password.JournalPassword(j[4][k])
+ return journal
+
def getjournal(self, classname, nodeid):
""" get the journal for id
raise
if res:
# we have unsaved journal entries, return them
- return res
+ return self.fix_journal (classname, res)
raise IndexError('no such %s %s'%(classname, nodeid))
try:
journal = marshal.loads(db[nodeid])
db.close()
if res:
# we have some unsaved journal entries, be happy!
- return res
+ return self.fix_journal (classname, res)
raise IndexError('no such %s %s'%(classname, nodeid))
db.close()
# add all the saved journal entries for this node
for nodeid, date_stamp, user, action, params in journal:
res.append((nodeid, date.Date(date_stamp), user, action, params))
- return res
+ return self.fix_journal (classname, res)
def pack(self, pack_before):
""" Delete all journal entries except "create" before 'pack_before'.
raise TypeError('new property "%s" not a '
'Password'%propname)
propvalues[propname] = value
+ journalvalues[propname] = \
+ current and password.JournalPassword(current)
elif value is not None and isinstance(prop, hyperdb.Date):
if not isinstance(value, date.Date):
raise hyperdb.DatabaseError(_('Database open read-only'))
self.db.destroynode(self.classname, nodeid)
- def history(self, nodeid):
- """Retrieve the journal of edits on a particular node.
-
- 'nodeid' must be the id of an existing node of this class or an
- IndexError is raised.
-
- The returned list contains tuples of the form
-
- (nodeid, date, tag, action, params)
-
- 'date' is a Timestamp object specifying the time of the change and
- 'tag' is the journaltag specified when the database was opened.
- """
- if not self.do_journal:
- raise ValueError('Journalling is disabled for this class')
- return self.db.getjournal(self.classname, nodeid)
-
# Locating nodes:
def hasnode(self, nodeid):
"""Determine if the given nodeid actually exists
l.append((OTHER, k, [float(val) for val in v]))
filterspec = l
-
+
# now, find all the nodes that are active and pass filtering
matches = []
cldb = self.db.getclassdb(cn)
elif isinstance(prop, hyperdb.Interval):
value = date.Interval(value)
elif isinstance(prop, hyperdb.Password):
- pwd = password.Password()
- pwd.unpack(value)
- value = pwd
+ value = password.Password(encrypted=value)
d[propname] = value
# get a new id if necessary