[Zope] dtml
Dieter Maurer
dieter@handshake.de
Thu, 30 Aug 2001 23:04:06 +0200 (CEST)
Hector G writes:
> i'm new qith zope and i was trynig to study dtml with the dtml guide
> ,but i don'u understand when is necesary to use "_" and when"_."
>
> And i don't understan when :
> gatattr(O,name)
Seems you want some background reading....
Look at the Zope book or
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
"_", the DTML namespace, behaves both like an object
with attributes and like a mapping.
You use the attribute access syntax, "obj.attr", when
you want to access attribute "attr" of object "obj".
If the "attr" is not a constant name but an expression,
you would use "getattr(obj,attr)".
The attributes of "_" are described in the Zope online help
--> Zope Help --> DTML Reference --> "functions".
A mapping maps keys to values. You use the subscription
syntax, "map[key]", to access the value associated with "key".
The mapping "_" maps all the (currently) defined variables,
the attributes of the current object and its acquired attributes
and the request variables (this is a simplified explanation;
read the mentioned resources to get a clearer picture).
Thus, you use "_[name]" to access the value currently bound
to "name". If "name" is constant, you can (often) simply use
"name". This is not equivalent (read the resources....), however!
Dieter