[Zope] Migration pains going to Zope 2.8

Richard Jones richardjones at optushome.com.au
Wed Aug 24 22:06:09 EDT 2005


On Thu, 25 Aug 2005 04:36 am, Dieter Maurer wrote:
> Does your "addValue" have a "__name__" attribute with value "addValue"?

In py2.3 (at least) functions get a __name__ automatically:

Python 2.3.5 (#2, Mar 29 2005, 15:41:06)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
...  pass
...
>>> foo.__name__
'foo'
>>>


> If so, you may want to analyse the "FactoryDispatcher" mentioned
> above.
>
> You get it (in an interactive interpreter) via
>
>     app.manage_addProduct[<your Product>]
>
> In its class, you should find your contructors as
> well as permission attributes of the form "<constructor_name>__roles__".
>
> Apparently, "addValues__roles__" is missing (for whatever reason).

The ProductContext is creating the attributes correctly on the Product's 
custom FactoryDispatcher class. The correct class is being used, and the 
*__roles__ attributes are all present and accounted for when the validate() 
is invoked. The problem appears to be that we don't even get up to checking 
those attributes. The addValues function has no __roles__ attribute, so we 
wander into __roles__ attribute checking on the container and fall about 
laughing. So I added __roles__ to addValues:

  addValues.__roles__ = ('Manager', )

and now everything works. I even removed the ModuleSecurityInfo declarations, 
since they appeared to have no effect at all. There's probably some API for 
setting that __roles__ attribute, but I'm stuffed if I can find it.


Thanks for the help Dieter,

     Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20050825/7482d227/attachment.bin


More information about the Zope mailing list