Re: [Zope-dev] Acquisition, __getattr__ and making a Proxy/Symlink class

2001-09-26 Thread Chris Withers

> Also, be sure optimize, because __getattr__ gets called *a lot*.  In 
> some cases, I've measured it getting invoked hundreds of thousands of 
> times in a single request!

Ouch! How was that happening?

Chris


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Acquisition, __getattr__ and making a Proxy/Symlink class

2001-09-26 Thread Dieter Maurer

Lupus Yonderboy writes:
 > 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:
 > ...  Symbolic Link ...
I did not read your lengthy explanation, just got the above keyword

There is a "SymLink" product of Shane. Check whether it does what you
need.


Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Acquisition, __getattr__ and making a Proxy/Symlink class

2001-09-26 Thread Shane Hathaway

Lupus Yonderboy wrote:

> 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.


Here are a few hints for avoiding recursion in __getattr__():

- Every attribute __getattr__ accesses that is expected to be in 
self.__dict__ should also be a class attribute.

- Use self.__dict__.get().

- The "self" passed to __getattr__ is *not* wrapped, as it is for other 
methods, meaning you can't access anything in the object's context from 
__getattr__.  CMF uses a combination of __of__(), volatile attributes, 
and Zope's threading model to get around this.

Also, be sure optimize, because __getattr__ gets called *a lot*.  In 
some cases, I've measured it getting invoked hundreds of thousands of 
times in a single request!

Shane


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Acquisition, __getattr__ and making a Proxy/Symlink class

2001-09-26 Thread Steve Alexander

Lupus Yonderboy wrote:

> 
> 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.


Have you looked at the __bobo_traverse__ traversal hook?

   http://www.zope.org/Documentation/ZDG/ObjectPublishing.dtml

--
Steve Alexander
Software Engineer
Cat-Box limited



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Acquisition, __getattr__ and making a Proxy/Symlink class

2001-09-25 Thread Lupus Yonderboy

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

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )