[Zope-dev] Copy & paste in folderish products

Martijn Faassen m.faassen@vet.uu.nl
Wed, 01 Dec 1999 17:54:36 +0100


Hi there,

As mentioned earlier on the list, I've written a Folderish product
(ZFormulatorForm) to which objects can be added (objects with classes
derived from a Field class). This works thanks to the Other Martijn, but
copy & paste (as well as rename) does not. With more help from the Other
Martijn I've tracked down the failure to line 360 of OFS/CopySupport.py:

if hasattr(meth, '__roles__'):

This hasattr fails (meth has no __roles__ attribute) as a result of
which the method _verifyObjectPaste raises a CopyError exception.

What is __roles__ supposed to do? I've tracked down 'meth' as the
attribute of ZFormulatorForm that is used to add a field to the form,
for instance:

manage_addBasicFieldForm

'meth' itself isn't called, only the __roles__ attribute is checked, to
perform a security check.

My 'meth' is a special class of my own. This is due to some hackery to
make the entire setup work to my liking; HTMLFile does not work (see
another earlier post; it seems HTMLFile does now allow single .dtml file
to be used in multiple ways; i.e. <dtml-var foo> will always evaluate to
the latest definition of 'foo' in a HTMLFile construction). I suspect
the __roles__ attribute might be defined in MethodObject.so. Should I
start digging into the .c sources or am I on the wrong track?

What is __roles__ supposed to contain?

Another associated problem is that 'add <field meta_type>Fields'
security fields are not added to the security screen of ZFormulatorForm.
This may be due to my changing the meta_types attribute of
ZFormulatorForm manually when registering fields with it. But I wouldn't
think this would matter, as ZFormulatorForm is only registered with Zope
*after* my meddling. But for some reason no security permissions for the
adding of the fields are appearing... Perhaps this is also dependent on
the mysterious __roles__ attribute of the manage_add methods?

I really wish there were documented interfaces for the Zope sources at a
time like this..

Regards,

Martijn