[Zope3-Users] Re: Traversing to nearest site

Philipp von Weitershausen philipp at weitershausen.de
Fri Mar 25 12:47:22 EST 2005


jürgen Kartnaller wrote:
> Ok,
> nobody knows, me too.

I knew, but you were too quick :)

> I did this :
> 
> I implemented a traverser :
> 
> 
> from zope.app.component.hooks import getSite
> from zope.app.traversing.namespace import SimpleHandler
> 
> class site(SimpleHandler):
> 
>     def traverse(self, name, ignored):
>         return getSite()
> 
> 
> And registered it this way in my configure.zcml :
> 
>   <adapter
>       name="site"
>       provides="zope.app.traversing.interfaces.ITraversable" for="*"
>       factory="coma.traversing.site"
>     />
>   <view
>       name="site"
>       type="*"
>       provides="zope.app.traversing.interfaces.ITraversable" for="*"
>       factory="coma.traversing.site"
>     />
> 
> Now I can use ++site++ to traverse to the nearest site.
> 
> Can one of you geeks please let me know if this is the right way to 
> implement this feature ?

Yes. Well done.

Philipp



More information about the Zope3-users mailing list