[Zope-Coders] Changes to ObjectManager, Role, and User in Zope2

Zachery Bir zbir at urbanape.com
Wed Mar 17 10:48:04 EST 2004


On Mar 17, 2004, at 10:25 AM, Zachery Bir wrote:

> I propose the following changes to OFS.ObjectManager._setObject:
>
>         if set_owner:
>             object.manage_fixupOwnershipAfterAdd()
>
>             # Try to give user the local role "Owner", but only if
>             # no local roles have been set on the object yet.
>             if hasattr(object, '__ac_local_roles__'):
>                 if object.__ac_local_roles__ is None:
>                     user=getSecurityManager().getUser()
>                     if user is not None:
>                         id=user.getId()
>                         name=user.getUserName()
>                         if name != 'Anonymous User':
>                             object.manage_setLocalRoles(id, ['Owner'])

Actually, since the emergency user is caught by 
object.manage_fixupOwnershipAfterAdd and prevented from doing so, we 
can test with this:

         if set_owner:
             object.manage_fixupOwnershipAfterAdd()

             # Try to give user the local role "Owner", but only if
             # no local roles have been set on the object yet.
             if hasattr(object, '__ac_local_roles__'):
                 if object.__ac_local_roles__ is None:
                     user=getSecurityManager().getUser()
                     if user is not None:
                         id=user.getId()
                         if id is not None:
                             object.manage_setLocalRoles(id, ['Owner'])

and not bother with the special getId() on SpecialUser objects.

Zac




More information about the Zope-Coders mailing list