[Zope-dev] Renaming ZClass instances in 2.2.0
Steve Alexander
steve@cat-box.net
Sat, 29 Jul 2000 20:01:22 +0100
In Zope 2.2.0, I can't rename ZClass instances.
When you rename something, lib/python/OFS/CopySupport.py's
_verifyObjectPaste() method gets called with the object you're renaming
as an argument. The method checks that the current user is authorized to
create objects of that kind, and that the current user is authorized to
create that object in the current context.
The problem seems to be that, in the case of renmaing a ZClass instance,
when the ZopeSecurityPolicy tries to get a __roles__ attribute for the
instance you're renaming, it can't find one.
I'm way out of my depth here, but I can get it to work again by adding
to the function PersistentClassDict() in lib/python/ZClasses/ZClass.py
(line 195 or so):
dict['__roles__']=('Manager',)
so that it looks like this:
def PersistentClassDict(doc=None, meta_type=None):
# Build new class dict
dict={}
dict.update(Template.__dict__)
if meta_type is not None:
dict['meta_type']=dict['__doc__']=meta_type
if doc is not None:
dict['__doc__']=doc
dict['__roles__']=('Manager',)
return dict
This only works for ZClasses defined after the change, though.
I have absolutely no idea what the side-effects of this change are, and
I'm not even entirely sure what it does :-)
It seems to fix the problems of renaming DataSkin-derived ZClasses too.
I've looked though the recent CVS checkins, and I can't see a fix for
this yet. I've also looked through the Collector, and I can't see this
problem reported.
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net