* mario ruggier wrote [2005-10-07 19:30:00 +0200]: > In particular, (in contact.py) wouldn't: > > class ContactAdmin(DulcineaPersistent, PermissionManager): > ... > > that, notice, is not a User, be more appropriately named something like: > > class ContactPermissionManager(DulcineaPersistent, PermissionManager): I thought that too, when I first started looking at it. I suspect they chose get_admin simply because its a lot shorter than get_permission_manager! eg: f = Permissioned() print f.get_permission_manager().valid_permissions Maybe it could be called get_pm Incidentally, I like the new additions to dulcinea.spec, even add_getters and add_setters, which I wasn't sure I would like, and especially specify. Its not clear in this sample of my subclass of PermissionManager etc how much repetitive code the combo removes, (specify is particularly nice in this regard) but as I go about refactoring stuff, I'm finding things much more readable now. example -------------------- from dulcinea.permission import PermissionManager from dulcinea.spec import nspec, specify, subclass, add_getters class GenericPermissionManager(PermissionManager): """ A generic PermissionManager that could be used as-is for many objects that need managed access to attributes and methods. Class attributes defined here: valid_permissions : dict {key : permission decription} """ valid_permissions = { "system": "Allow things normally done by the software system.", "owner": "Owner has full access to this object.", "manage-permissions": "Allow changing of permissions for this object.", "manage-settings": "Allow changing settings of this object", "view": "Can view but not change properties of this object", "update": "Can change properties of this object", "delete": "Can delete properties or information associated with this object", "destroy": "Can completely destroy (delete) this object", } def __init__(self): PermissionManager.__init__(self) class Permissioned: """ Set/get a PermissionManager for object to be managed. Example usage: class Foo(Permissioned): def __init__(self, pm=GenericPermissionManager): Permissioned.__init__(self, permission_manager=pm) """ permission_manager_is = nspec(subclass(PermissionManager)) default_pm = GenericPermissionManager permission_manager = None def __init__(self, permission_manager=default_pm): specify(self, permission_manager=permission_manager) def set_permission_manager(self, permission_manager): """(permission_manager : PermissionManager instance) """ assert self.permission_manager is None, \ "changing a pm once set should be done deliberately..." specify(self, permission_manager=permission_manager) add_getters(Permissioned)