AW: [Zope] Accessing higher namespace

Karsten Kraus Karsten.Kraus@web.de
Fri, 24 Aug 2001 18:50:32 +0200


> Karsten Kraus writes:
>  > if got a little problem with dtml-namespaces.
>  > I'm using the dtml-in-tag for iterating over the results of a 
> python script.
>  > I want to compare the results with the id of the document 
> which calls the
>  > python script.
>  > My Question is: how can I access the namespace "above" the
>  > dtml-in-namespace?
>  > 
>  > Example
>  > <dtml-let test="this().getId()">
>  > <dtml-var test>	// prints the documents id.
>  > <dtml-in "pythonmethod()">
>  > <dtml-var test>	// 'test' is not in my namespace anymore! What now?
> Why not. It should remain there!
>  > </dtml-in>
>  > </dtml-let>
> 

It doesn't, if I use dtml-in with the python method. 
But it works as expected if I use e.g. "_.range(5). 
I think the problem is somwhere in the python script, so 
here it is:

------ #python script# get_folders() -------------------

# get nearest folder
def get_nextlevel(object):
  parent = object.getParentNode()
  if(parent.meta_type != 'Folder'): parent = get_nextlevel(parent)
  return parent

# Return List of Sub-Folders
def get_folders(object):
  if(object.meta_type != 'Folder'): object = get_nextlevel(object)
  folders = []
  for folder in object.objectValues('Folder'):
    # don't add pics-Folders etc.
    if(folder.getProperty('add_to_nav')): folders.append(folder)

  if(len(folders) <= 0): 
    # If there are no folders to add to navigation, go on level up
    folders =  get_folders(get_nextlevel(object))
  else:
    # add "back-link" if we're not in the main or root folder
    if(not object.getProperty('main_nav')): folders.insert(0,object);

  return folders

# Let's start
return get_folders(context)

-----------------------------------------------------------

??Any idea anyone??

As I'm not sure if I just don't see the typo - here's the dtml-method
calling the python script.

----- #dtml-method# navigation ----------------------------

<TABLE border="0" cellspacing="1" cellpadding="2" width="132">
  <dtml-let test="100">
    <dtml-in "get_folders()">
       <dtml-var test>
        <TR><TD class="nav">
          <A href="&dtml-absolute_url;">
          <dtml-if expr="aq_parent.getProperty('main_nav')">
            <dtml-var title_or_id upper>
          <dtml-else>
            <dtml-var title_or_id>
          </dtml-if>
          </A></TD></TR>
    </dtml-in>
   </dtml-let>
</TABLE>

----------------------------------------------------------

Both objects are located in an "Transparent Folder".
But the problem occurs even if I put them in the parent folder.


Hope on of you guys can help ;-))

Thanks

Karsten