[Zope] Using property() function in Zope 2.8
maxm at mxm.dk
Thu Jul 6 14:19:36 EDT 2006
I needed to dynamically generate local roles for an Archetypes based
content object today.
Different layers in my Plone stack breaks all rules and reads the
__ac_local_roles__ variable directly, instead of calling get_local_roles()
So to maximize the compatibility between Zopes zmi and Plones local
roles management I wanted to make '__ac_local_roles__' a property with
setters and getters.
My AT class was based via a few hops on:
'from ExtensionClass import Base'.
And as far as I understand from the release notes Zope 2.8.x should use
extension classes based on new style classes. So the property function
This code below works in plain Python. But when I add them to my zope
class, and run the tester() method I get an "Attributer Error:
# -*- coding: latin-1 -*-
def set__ac_local_roles__(self, value):
self.__mxm__ac_local_roles__ = value
__ac_local_roles__ = property(get__ac_local_roles__,
"Local roles on object")
if __name__ == '__main__':
p = PropTest()
p.__ac_local_roles__ = 'working'
hilsen/regards Max M, Denmark
IT's Mad Science
Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96
More information about the Zope