[Zope] Re: Adding __setitem__ to a formulator field?
Jeff Kowalczyk
jtk@yahoo.com
Wed, 9 Oct 2002 15:16:11 -0400
What mechanism maps __guarded_setitem to the [key] syntax? I removed __setitem__ from my
formulator field class and replaced it with the add_guarded_writes attribute and this
method (note the absence of security.declareProtected())
add_guarded_writes = 1
def __guarded_setitem__(self, index, value):
if getSecurityManager().checkPermission(
'Access contents information', self):
self[index] = value
else:
raise Unauthorized('__setitem__')
But I don't seem to have it hooked up right...
>>> import Zope, Products, ZEO, ZODB
>>> storage = ZEO.ClientStorage.ClientStorage(('localhost', 8800))
>>> db = ZODB.DB(storage)
>>> conn = db.open()
>>> dbroot = conn.root()
>>> app = dbroot.get('Application')
>>> app.Formulator.form3.str1['required'] = 0
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
AttributeError: __setitem__
>>>