[Zope-dev] Making Role.py's __ac_local_roles__ play nicely with computed attributes

Florent Guillaume fg at nuxeo.com
Thu Nov 25 10:03:47 EST 2004

> we currently have a project where we calculate local roles dynamically.
> This involves using a computed attribute as an __ac_local_roles__
> replacement. Unfortunately this doesn't mix too well with assigning them
> manually, although our computed attribute takes care.
> Why is this and what can we do against that?
> __ac_local_roles__ is a dict. It's not a PersistentDictionary, but an
> ordinary Python dict. Therefore, to obey the rules of persistence, the
> Role.py local role machinery reassigns __ac_local_roles__ after every
> change.
> I'd like to change this, so that Role.py sets _p_changed instead, which
> is what it tries to signal. Additionally you need to explicitly assign
> __ac_local_roles__ instead of just getting
> dict=self.__ac_local_roles__ or {}
> so this becomes
> dict=self.__ac_local_roles__
> if dict is None:
>     self.__ac_local_roles = dict = {}
> This change works without disrupting the unit tests and I would love to
> get it on Zope 2.8. Any objections?
> I take silence as a 'no objections'.

Ok with me.

Although there must be a number of products out there that manipulate
local roles directly and don't obey that... But probably at this point
it's not important.

But please add a small comment to the code to the effect that you don't
want to re-assign __ac_local_roles__ because it may be a complex object.


Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com

More information about the Zope-Dev mailing list