Sorry, my __bobo_traverse__ method is working, the PARENTS stack is exactly as I would hope, with my module as the parent of the category, rather than the root.
 
Here's the whole story:
 
/
    index_html    (dtml method)
    index.html    (dtml method)
    category (Folder)
        foo.html    (dtml method)
    blah    (Module)
        category (Folder)
            header.html    (dtml method)
    weather    (Category)
 
/index_html:
    <dtml-var index.html>
 
/index.html:
    <dtml-var standard_html_header>
 
    <dtml-if expr="meta_type == 'Category'">    <!-- true in cases of url like /blah/weather -->
        <dtml-call expr="REQUEST.set('splevel', category)">
    </dtml-if>
 
    <dtml-with splevel mapping>
        <dtml-var header.html>
    </dtml-with>
 
    <dtml-var standard_html_footer>
 
 
Now, what I hope to happen is that the dtml-with would bind to the /blah/category folder, and therefore be able to find header.html.  However, somehow it's getting the /category folder instead, which doesn't have header.html.
 
Anyone understand why this is happening?
 
Thanks again,
-Randy
----- Original Message -----
Sent: Sunday, December 03, 2000 8:08 PM
Subject: [Zope] siblings of me, rather than of parent

My site has two main classes of objects, Modules (and their derivatives), and Categories.  A normal setup might look something like this:
 
root
    blab    (Module)
    weather (Category)
        rain (Category)
        sun (Category)
    region (Category)
 
I need to handle URLs like /root/blab/weather.  The problem is that I need weather.__of__(blab) on the stack, rather than weather.__of__(root) on top.  This is because blab (in some cases) overrides default behaviors from root.
 
I thought the proper way to do this was by adding a __bobo_traverse__ method to my Module, like this:
 
   def __bobo_traverse__(self, REQUEST, name):
        try:
            parents = REQUEST['PARENTS']
            parent = parents[-2]
            if hasattr(parent, name):
                ob = getattr(parent, name)
                if ob.meta_type == 'Category':
                    return ob.aq_inner.__of__(self)
        except:
            pass
 
        return getattr(self, name)
 
But that doesn't seem to change anything, although it does perform the return (and doesn't throw any exceptions.)
 
Basically, I'm trying to offer my siblings as if they were my children, so if they fail to offer something, it will be looked for in me, rather than my parent.
 
Thanks,
-Randy

Reply via email to