[Zope] Lost in name Space...

Pierre-Julien Grizel grizel@mouli.net
Fri, 26 Jan 2001 12:54:30 +0100


You can try

<dtml-with "RandomGreeting">
	<dtml-var Greet>
</dtml-with>


Think of the namespace as a stack : whenever you address an object using
the dot notation as you did, you do not put the RandomGreeting folder in
the stack.
When you use the <dtml-with> tag, you just put RandomGreeting up the
stack.

Namespace stack with the dot notation :

-----------
|  Greet  |  (Remember a DTML Method applies to its calling folder !)
-----------
|    /    |
-----------


Namespace stack with <dtml-with> :

-------------------
|      Greet      | 
------------------|
|  RandomGreeting | 
------------------|
|        /        |
-------------------



That's it !




P.-J.


Prateep Siamwalla wrote:
> 
> <<Sorry if you happen to see this for the third time, I have been trying
> to post this on egroups, but have failed on several occasions.>>
> 
> Hi,
> Zope newbie here, a bit lost on namespaces...
> 
> I have created a folder in the zope root called "RandomGreeting".
> Inside this folder, there is one DTML METHOD called "Greet".  "Greet"
> contains the following line:
> 
> <p><dtml-var expr="_.whrandom.choice(sayHellos)"></p>
> 
> "sayHellos" is a property of the "RandomGreeting" folder, and
> contains 4 lines which are various ways to say
> hello : "Ola","Hi","Bonjour","Sawasdi".  The purpose of this method
> is to print out a random greeting.
> 
> Everytime i click "View" for this DTML Method, i get a random hello.
> Fine, that is exactly what I want.
> 
> The problem is that I am trying to use this "method" from its parent
> folder (the root folder as a matter of fact).  I have inserted the
> following bit into the top level "index_html" DTML Method of my Zope
> root near the begining, so that it produces a random hello on the
> front page everytime someone accesses it.
> 
> I have tried :
> <dtml-var RandomGreeting.Greet>
> <dtml-var RandomGreeting.Greet()>
> <dtml-var "RandomGreeting.Greet()">
> <dtml-var /RandomGreeting/Greet>
> 
> all of these, to know avail.  I am getting either a NameError or
> KeyError.  I am pretty sure I'm missing a simple concept here. It is
> possible to call functions from child objects is it not?
> 
> Please help with some enlightenment.  Many thanks in advance.
> 
> teep
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

-- 
If the only tool you have is a hammer, 
    you tend to see every problem as a nail.
Si le seul outil dont vous disposez est un marteau, 
    vous avez tendance à voir chaque problème comme un clou. 
                                       --Abraham Maslow