[Zope] Syntax Issue with dtml-in iteration

Dan Shafer dan at danshafer.com
Thu Aug 14 19:59:53 EDT 2003


(Sorry if this posts twice. I posted earlier but from an unsubscribed 
account and I'm assuming that one will get booted out by the system.)

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?




More information about the Zope mailing list