On Oct 7, 2005, at 2:42 PM, mario ruggier wrote: > > I'd be interested to understand how you have modeled it now. I do > not need any conversion utilities... looking at the code (and > examples... ;-) would be very much appreciated. # PersistentSet is a new durus type. # string is a new spec that includes unicodes and ascii strs. class Permissions (PersistentDict): data_is = {string:sequence(either(Persistent, True), PersistentSet)} def grant(self, permission, granter): require(permission, string) require(granter, either(Persistent, True)) if permission not in self: self[permission] = PersistentSet([granter]) else: self[permission].add(granter) def ungrant(self, permission, granter): require(permission, string) require(granter, either(Persistent, True)) if self.is_granted(permission, granter): self.data[permission].remove(granter) if len(self.data[permission]) == 0: del self.data[permission] def is_granted(self, permission, granter): return granter in self.get(permission, []) class DulcineaUser(DulcineaPersistent): global_permissions = { "act-as": "Allow to act as another user.", "create-users": "Allow the creation of other users.", "manage-permissions": "Allow changing of permissions.", "staff": "Is a member of the staff", "system": "Allow to do things normally done by the software system.", } permissions_is = Permissions ... def is_admin(self): return self.is_granted('staff') def is_granted(self, permission, granter=True): return self.get_permissions().is_granted(permission, granter)