[Zope3-Users] Re: Traversing to nearest site

jürgen Kartnaller j.kartnaller at cable.vol.at
Thu Mar 17 12:53:34 EST 2005


Ok,
nobody knows, me too.

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 ?

Thanks
Jürgen

jürgen Kartnaller wrote:
> Hi all.
> 
> I'm looking for a view like ++etc++ which allowes to traverse to the 
> nearest site.
> 
> Something like : http://localhost:8080/coma/competition/++site++
> 
> In my case come is the site root and this url should go to coma.
> I will use this for a menu entry which says 'go back to root' from 
> wherever I am in my subfolders.
> 
> If it does not already exist I would try to implement it.
> 
> 
> Jürgen



More information about the Zope3-users mailing list