[Zope-dev] zpatterns: rackmountables must be of-wrapped

Jephte CLAIN minf7@educ.univ-reunion.fr
Thu, 25 May 2000 13:56:44 +0400


"Phillip J. Eby" a écrit :
> >So: retrieveItem, createItem use vanilla objects
> retrieveItem and createItem are not intended to be public methods; the only
> reason they don't begin with an "_" is that I wanted to make it possible
> for them to be implemented as DTMLMethods or PythonMethods.
you missed the point. I wasn't that clear neither ;-)

I know that retrieveItem and createItem are not public API, and are
meant to be overidable.
I believe that telling the rackmountable what rack it belongs to in
getItem and newItem it not sufficient. It has to be wrapped in the
context of the rack with something like:

# this works for me
item = self.retrieveItem(key)
if item is not None:
	item._setRack(self.aq_inner)
	return item.__of__(self) # keep other acquisition wrappers,
				# no need to get aq_inner

or:

# untested
item = self.retrieveItem(key)
if item is not None:
	rack = self.aq_inner
	item._setRack(rack)
	return item.__of__(rack)

When I don't wrap items like this, I get strange unauthorized errors.
Only the super user can use the items. All the other users (Managers or
not) can't.

Remember that I use python classes as rack-mountables, and they don't
get the fancy acquisition wrapping that zclasses get.

regards,
jephte clain
minf7@educ.univ-reunion.fr