[Zope] Syntax for dtml-in property check?

Dan Shafer dan at danshafer.com
Thu Aug 14 19:44:09 EDT 2003


I'm tripping over what seems like should be fairly straight-forward 
syntax. Hopefully someone here can point out what I'm overlooking.

Situation:

I have a folder that contains a bunch of folders, each of which has a 
property named "coach_id" that I've created and updated 
programmatically.

Task:

I have one user who is allowed to see the contents of all folders. All 
other users are restricted to folders where they are the Coach (i.e., 
where their AUTHENTICATED_USER== the coach_id of a particular folder).

Approach:

I have a DTML method that loops over all the folders and displays a 
list of folder links for each folder the user is authorized to see. 
That method works fine when I don't try to limit it by authenticated 
user name. I use a simple <dtml-in> construct for this purpose:

<dtml-in expr="objectValues('Folder')" sort=title_or_id>

I placed a <dtml-if> statement inside the <dtml-in> construct. That is 
where the problem is popping up. My if statement should look like this, 
I think:

<dtml-if expr="(AUTHENTICATED_USER.getUserName() == 'Magic User') | 
(AUTHENTICATED_USER.getUserName() == sequence-var-coach_id)">

But I get an error from Zope indicating the public variable "sequence" 
isn't defined? I'm in a <dtml-in> so I *believe* sequence should have 
meaning. Am I wrong?

I tried this with only one logic clause in case the problem was the OR 
syntax or logic. But this:

<dtml-if expr="AUTHENTICATED_USER.getUserName() == 
sequence-item.coach_id">

produces the same "global variable sequence not defined" error.

If i hard-code a name into that same sequence, the operation works but, 
of course, does not filter on the coach_id.

<dtml-if expr="AUTHENTICATED_USER.getUserName() == 'Magic User'">

It seems evident that I'm missing something about how <dtml-in> works. 
I have believed that in the midst of a <dtml-in> I'm iterating over a 
sequence that is represented by the built-in Zope variable, "sequence." 
Evidently I'm wrong.

Can anyone help?

I feel like I'm just guessing at random possibilities now. Obviously 
time to raise a white flag. (I have to say, this happens so often with 
Zope that I often wonder if I'm just too dense to get good at this. I 
try to read and follow docs, but things just always end up slightly out 
of phase for me.)




More information about the Zope mailing list