[Zope] Thoughts on <dtml-in ...> and related matters
The Famous Brett Watson
famous@nutters.org
Fri, 23 Mar 2001 19:07:25 +1100
I'm relatively new to Zope, and so unfamiliar with all the issues that this
might raise, but here are my thoughts on the dtml-in "sequence-item" issue.
It seems that what we have here is a specific instance of a general problem:
dtml variables which aren't readily accessible in Python because they use
identifiers that aren't valid in Python. In the first instance I would
suggest a policy of making built-in dtml names Python-compatible. There
seems to be a lack of consistency in the naming conventions which would
benefit from this anyhow. Yes it's true that renaming any variable like this
can impact on already-written programs, but that's true of any change to the
namespace.
I've also noted that there is a large amount of confusion amongst Zope
newbies when it comes to the differences between the dtml any Python
namespaces -- understandably so. Even if you can understand what a namespace
is, what a context is, that there is a difference between Python and DTML in
terms of these concepts, and how acquisition works in general, it's still
damn hard to figure out exactly what identifiers are valid and associated
with what object in these circumstances. If anyone has a good tutorial on
the matter, please point me to it. As someone who is familiar with
programming language theory but new to Zope, I often find myself asking "WTF
is in my namespace now?" And there seems to be a high number of questions
relating to how to fetch dtml-accessable objects in Python.
A smoothing out of these differences would be beneficial to all, I think.
Finally, with regards to the idea of tying sequence-item and related
variables to other names (such as foo-item, bar-item, etc), I would
anticipate this being done by creating a loop control variable with
properties. For example, one could have the following.
<dtml-in mylist using="foo">
Key: <dtml-var foo.key>; value: <dtml-var foo.item>
</dtml-in>
This could be introduced as a *new* syntax for the dtml-in tag, such that
omitting the "using" attribute causes the old sequence-* suite of variables
to be used. This should obviate any issues with namespace pollution: the
programmer declares the new variable (and thus namespace) to populate.
Presumably the variable can also be declared in a way that makes it
directly-accessable in Python, too.
Like I say, I'm not familiar enough with Zope to know if all this is viable,
but it's the kind of behaviour that I'd go looking for if I thought it
existed.
Regards,
TFBW