[Zope-dev] getattr'ing proxy object's methods
Kent Polk
kent@goathill.org
12 Apr 2001 16:11:29 GMT
I have a product with a proxy class for building objects which
manage data for other objects. The proxy clients locate their proxy
via meta_type, similar to a sql connection_id and use acquisition
to establish parameters for each call. I want to pass method calls
made to the clients directly to the proxy, but in the context of
the client.
Right now, my clients have a method:
def Proxy(self):
"""Return the proxy associated with this object"""
return getattr(self, self.proxy_id)
which is used in conjunction with dtml-with to establish the
context:
<dtml-with Proxy>
<dtml-in "getTable(project=Project, [...])">
This works fine, however, I would like for the clients to automatically
pass method calls that they don't have on to the proxy. __setattr__
is not called for the proxy clients because the final URL component
specifies an acquired folder method, not the proxy client. I tried
__bobo_traverse__, but again, the final URL component is passed as
the argument instead of the method, so it's not clear exactly how
__bobo_traverse__ could make sense out of what needs to be done,
much less know what method was to have been called.
Is there a proper way to call a proxy object's method in this
context, directly in the product class, without using dtml-with?
Thanks!