[Zope] dtml-with in a pythonMethod?

Evan Simpson evan@digicool.com
Thu, 23 Mar 2000 22:01:37 -0500


----- Original Message -----
From: "Darran Edmundson" <Darran.Edmundson@anu.edu.au>
> I have a container ZClass Person.  Person has a (string) property
> CurrentPosition which gives the id of a ZClass instance contained
> in Person.
>
> list = []
> for person in self.objectValues('Person'):
>      position = _.getitem(person.CurrentPosition)
>      list.append(person.LastName, position.anyProperty))
>
> I think the question really comes down to: how does one
> achieve <dtml-with name> in a pythonMethod?

One doesn't.  Instead one uses local variables, as you did with 'person'.
Your solution is almost complete, actually, and should work if you replace
'_.getitem(person.CurrentPosition)' with one of the following (I'm not sure
which, you'll need to experiment):

person[person.CurrentPosition]
getattr(person, person.CurrentPosition)
person.aq_acquire(person.CurrentPostion)

Sorry I can't be more specific.  In general, though, any place you would use
dtml-with in DTML, you set up a local variable in PythonMethods.

Cheers,

Evan @ 4-am & digicool