[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Using Zope Page Templates

webmaster at zope.org webmaster at zope.org
Sat May 1 03:52:22 EDT 2004


A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx#2-29

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

    Zope defines a small set of built-in variables such as 'request'
    and 'user', which are described in the chapter entitled "Advanced
    Page Templates":AdvZPT.stx. You will also learn how to define your
    own variables in that chapter.

      % Anonymous User - Nov. 20, 2003 4:05 am:
       The example 'path expressions' we've seen so far are:

       here/title
       here/insertme
       template/title
       request/URL
       user/getUserName
       container/ObjectIDs

       Perhaps just a very small introductory discussion of these top-level paths (built in variables ?): 'here',
       'template', 'request', 'user' and 'container' might not go astray... and of course examples, examples,
       examples of how they can be used and why they are cool.

      % Anonymous User - May 1, 2004 3:52 am:
       Of course, an obvious question is: where's the list of possible "path expressions"? What's the list of
       objects and attributes/properties that they have? I can't find one anywhere, which makes learning TAL a case
       of poring over examples (or even the Python source code) to try and find out. Not good, guys.
       Anyway, here's something that might help: create an external (Python) method in the root folder (I call it
       'dirt') and put the following python script in the Extensions folder of your instance, called 'dirt.py':
       def dirt(self):
         str="Strings\n"
         for x in dir(self):
           if hasattr(self,x):
             y = getattr(self,x)
             if type(y) == type(str):
               str=str+`x`+': "'+y+'"\n'
         str=str+"\nOthers\n"
         for x in dir(self):
           if hasattr(self,x):
             y = getattr(self,x)
             if type(y) != type(str):
               str=str+`x`+'\n'
         return str

       Now, if you add 'dirt' to the end of any Zope URL (even just 'http://myhost/dirt'), you'll get a dump of all
       the attributes of the container object. Strings are shown first, then all the other guff. It's not the
       reference that should be here, but it's helped me.
       Incidentally, if the python code comes out all mucked up, sorry, but there's no 'preview comment' button on
       this form...
       ben_



More information about the ZDP mailing list