[Zope-dev] ZPatterns question

Steve Alexander steve@cat-box.net
Thu, 28 Dec 2000 22:49:55 +0000


Steve Alexander wrote:

>
>   return getattr(container.path.to.somewhere, name)
> 
> That's the simple version, and it won't give the traversed-to object the 
> correct context most of the time. To do that, I'd need to use an 
> external method, and use the __of__ method to give the returned object 
> an appropriate context.

However, if all you are doing is saying "does this object have the named 
attribute? if not, get it from another specialist", and you're using 
Specialist.getItem() to do the latter part, then the object you want 
comes ready-wrapped in the appropriate context, courtesy of the Rack 
that gives it to you!

-- 

Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net