[Zope] <dtml-var> namespace resolution monitoring?
Dylan Reinhardt
zope@dylanreinhardt.com
Sat, 08 Feb 2003 15:49:31 -0800
At 02:48 PM 2/8/2003, Derek Basch wrote:
>Can anyone suggest some strategies for determining
>where a <dtml-var> is resolving its value from?
First off, are you certain that this mystery variable isn't some "magic"
method provided by Zope? You may want to post the name of the variable
just to be sure. Assuming that this isn't the case, it can only be coming
from four places:
1. It's part of your REQUEST object.
2. It's an object contained by the folder your script is in or any of that
folder's parents.
3. It's provided by some object referenced in your URL
4. It's provided by some object you're traversing in the script or are
otherwise putting into the namespace
There are several things you can do to narrow this down, including:
- Comment out all of the script except for that <dtml-var>... is the
value still resolved?
- Put a method of the same name in the same folder... is that method's
value used instead? If so, keep moving the method up the hierarchy until
the effect disappears.
- If you using a URL that differs from the "physical" path of the object,
take a close look at any objects included in the URL.
- If commenting everything but the <dtml-var> breaks the variable, pay
particular attention to any objects referenced by <dtml-with>, <dtml-in>
and (un)restrictedTraverse. Your mysterious name provider probably lurks
within.
After you've figured out this mess, you should strongly consider re-writing
with Python Scripts. DTML should never be used for anything complicated
enough to defy easy inspection... but I'll spare you the lecture since you
didn't write it. :-)
HTH,
Dylan