[Zope-dev] Acquisition, __getattr__ and making a Proxy/Symlink class
Lupus Yonderboy
yonder8oy@yahoo.com
Tue, 25 Sep 2001 22:06:00 -0700 (PDT)
Hi folks,
I'm having some troubles trying to develop a
particular zope object and would really appreciate a
bit of help. I'll explain what I'm trying to do:
What we have is a tree of nodes rooted in a folder
(excuse my ascii art) like so:
+ DocumentRoot (folder)
+ a
+ b
+ c
+ d
+ e
+ e
+ f
+ g
+ X (proxy, pointing to 'e')
Here [a-g] are our node objects, and X is a
proxy-object. The proxy-object is intended to behave a
bit like a sybolic link with a few extra features.
I have looked at Shane Hathaway's Symlink product,
which does the linking job just fine. It allows us to
create a proxy that behaves just like the target, but
we also need the proxy-object to have it's own
attributes and methods.
In the above hierachy, the desired way of finding an
attribute of the proxy 'X' goes something like:
- look in the proxy object ('X')
- if not there look in the proxy target ('e')
- (maybe) if still not found acquire from aq_parent
('g')
- otherwise raise AttributeError
I guess we are wanting X to behave as though it were a
child of the object it links to, so X always behaves
as though it were X.__of__(e) (and possibly also a
child of g, ((X o g) o e) or ((X o e) o g) if not too
complicated).
I have tried hooking __getattr__ and have a hard time
avoiding recursion; I have taken a look at the
ever-productive Shane Hathaway's TransparentFolder
product as well but I think I am let down by my lack
of understanding of the particulars of acquisition.
Can anyone shed some light on how i might do this? All
objects under the DocumentRoot will be derived from
one of our base classes, so if we need to override
__getattr__ as per TransparentFolders it can be done
easily.
Cheers
__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com