From: "Bjorn Stabell" <[EMAIL PROTECTED]>
> How do you do dtml-with and dtml-let in a Python script?  (I.e.
> put something on the namespace)

You can't.  Scripts can use the DTML namespace in the same way that Python
expressions in DTML can, but that's it.

On the other hand, you can create (and pass along) all the local variables
you want.

> How do you give positional (not keyword) arguments to a DTML
> method; is there any difference?

Keyword arguments are put on top of the namespace.  You can't use positional
arguments, except the standard (None, _) idiom.  DTML was never meant to
pass arguments around, that's what the namespace is for, for what that's
worth :-P

> When is __call__ called, when is __str__ called, and when is
> index_html called?

When an object with a publishable 'index_html' attribute is the target of a
request, that attribute is used.  Failing that, or if the object is rendered
by calling it from DTML or a Script, __call__ is used.  DTML's "var" tag
will try to convert whatever you give it into a string, so if you give it an
object with a __str__ method, it'll get called.

> When does RESPONSE need to be passed; it can always be gotten
> from the REQUEST, right?


> Are namespace, _, REQUEST, and context just different names for
> the same thing?

Not quite.  The namespace, accessible in DTML as "_", is a pile of objects.
The REQUEST is a particular object created by ZPublisher to hold information
about the request, such as form variables and URL information.  The context
(or client, for DTML) is the object on which the method was called.  If the
DTML Method is the target of the request, or if you pass a client as the
first argument when calling it, the Method pushes it onto the namespace.
Also, the context (like any other Zope object) is acquisition wrapped.  The
ultimate acquisition parent of any publsihed object is a special wrapper for
REQUEST.  All this means that when you ask the namespace for the name "foo",
it will end up looking for it in the context, in the context's containers
all the way to the root, and the REQUEST.


Evan @ digicool

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to