In my Zope 2.7 Product, I'm trying to implement a special folder, which intercepts the publishing call to any subobject and wraps the entire call in another.
A concrete example: where the default action would be to traverse /MyProduct/SpecialFolder/something, and publish the attr 'something' from SpecialFolder, I want this to happen instead:
return mapply( something, blahblah...)
Why? I need to do stuff to the REQUEST before the object is called (this part wasn't difficult), and then do something *after* it's called - no matter what the results were. But only for publishables that live in or beneath the Special Folder.
In fact I have something working, but one big problem - it breaks management screens in a bad way. The implementation is pasted below. Is there some much simpler way to accomplish this behavior? And am I short-circuiting security machinery in some dangerous way?
id = meta_type = title = "Wrapper"
def __init__(self, publishable):
self.pub = publishable
render the results to the client
REQUEST = self.REQUEST
print self.__class__.__name__, 'calling', self.pub
return mapply(self.pub, REQUEST.args, REQUEST,
print self.__class__.__name__, 'done'
__call__ = index_html
def __bobo_traverse__ (self,REQUEST,key):
print '__bobo_traverse__', REQUEST.URL, key
stack = REQUEST['TraversalRequestNameStack']
target = getattr(self,key)
if stack: return target
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )