On Tue, 5 Feb 2002, John Hall wrote:
> 1.  How do I format an object to use in a <dtml-in> loop?  (I'm thinking
>     it needs to be a list of dict's).

dtml-in will accept four differen formats:  a list of objects with
attributes, a list of values, a list of dicts, or a list of pairs.

A list of objects is the most common case, and you get access to the
attributes by name inside the loop.  A list of values can only
be accessed using <dtml-var sequence-item>, which gives you access
to each item in the list in turn.  For a list of dicts you want
to specify the 'mapping' keyword on dtml-in, in which case the
keys of each dict can be used in dtml-var statements.  I'm not
100% sure what the list of pairs does, but I think one of the
two items in the pair goes into sequence-key and the other into

> 2.  How do I access a function or variable in a Product's python code
>     directly from DTML (or how do I add a callable method in Zope's DTML
>     namespace from a Product's python code?)  I think my major problem
>     here is lack of understanding of how Products are accesible within
>     the DTML namespace.

If you make the right security declarations you can probably access
a class variable from dtml.  What might be easier, though, is to
use the binding feature of DTMLFile to make the list available
when the method is called, via pre-declaration in your Product:

  [code that defines your class, including the class variable listOfMethods]

  yourAddMethod = DTMLFile('dtml/addForm',globals(),
        listOfMethod = yourclass.listOfMethods)

I'm not 100% sure this is going to solve your problem, but I've some
some stuff along these lines successfully, so it might.


Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to