[Zope] Understanding dtml and/or its variables
Dieter Maurer
dieter@handshake.de
Wed, 21 Feb 2001 19:47:45 +0100 (CET)
Damir Bartakovic writes:
> I am using ZnolkSQLWizard and it creates output like
> <INPUT TYPE="TEXT" NAME="table.name"> ...
>
> Now I am trying to force the user not to leave the field blank.
> Usually it works with <dtml-unless "somevariable"> ... once again!
> ....</dtml-unless>
>
> but with <dtml-unless "table.name"> ... I get the error:
> Error Type: NameError
> Error Value: table (The Traceback is at the end)
>
> Like it seems it don't like the '.'?
It likes '.' but interprets it differently:
Inside "...", you are in the realm of Python expressions.
In Python, the "." is not part of a name (as in DTML)
but it is an operator: the left operand is an object,
the right one a name and the result is the object's attribute
of the given name.
You can use, e.g. "_['table.name']" to access the object
with name "table.name" from Python.
The official Zope book and
URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
will tell you more about these issues.
Dieter