[Zope-Coders] Changes to ObjectManager, Role, and User in Zope2
Chris McDonough
chrism at plope.com
Thu Mar 18 02:19:02 EST 2004
On Wed, 2004-03-17 at 10:25, Zachery Bir wrote:
> So, as it is, while we except the Anonymous User from playing in
> setting the local role of Owner, we don't except the Emergency User
> from doing so, but in doing so, the Emergency User will never get back
> those roles assigned to it.
Given the shortcuts performed by the security machinery for the
emergency user, he probably doesn't really need the local role. Your
current patch looks good in that respect.
> 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'])
Your current patch is better, I think.
> The only thing this might obscure is an intention to provide for
> emergency users and anonymous users to always share the same local
> roles (since both would be mapped to and accessed with None as the key)
It would make sense for the emergency user and the anonymous user to
have distinct user ids as having them be the same seems like it might
become a security issue waiting to bite someone who is not completely
familiar with security internals. Also, although neither the anonymous
user nor the emergency user are presented as options on the local roles
tab, if they do happen to be granted local roles programmatically,
seeing "None" granted roles on the local roles screen is probably going
to confuse people.
To make life simple, maybe we should just give the anonymous user an id
of 'Anonymous' and the Emergency User an id of 'Emergency' and create a
"isSpecialUser" function that the _setObject code calls to figure out
whether it should grant local roles or not. A more complicated way
would be to create a persistent SpecialUserId class that always
evaluated to false, then the _setObject code could stay as it is, but it
might break some other existing code.
- C
More information about the Zope-Coders
mailing list