[Zope] calling a DTML method with arg
kapil thangavelu
kvthan@wm.edu
Fri, 22 Feb 2002 20:34:19 -0800
On Wednesday 13 February 2002 03:40 pm, John Hunter wrote:
> I have several pages where I want to list some information about
> patients in my database, and want to have a single DTML method called
> listPatient which takes pid (patient id) as an arg and lists the
> information for that patient. The basic idea is that I have many DTML
> Documents that need to list patients in a variety of contexts, and I
> want to have a single method that controls how patients are listed, so
> as I upgrade my database I won't have to change the patient listing
> format in many places
>
> Something like
>
> <dtml-in expr="get_pids()" mapping>
> <dtml-call expr="listPatient( 'pid=%s' % <dtml-var pid>)" >
> </dtml-in>
>
> But I am having trouble figuring out how to set up a DTML method to
> get an argument like this. Is this possible? Can you recursively
> nest DTML methods/documents?
this is a FAQ.. when you're in expr mode you need to explictly pass in the
args to a dtml method which takes three args, client, namespace, and keyword
args. also you can't and don't need to recursively nest the <dtml syntax when
you're in expr mode. expr mode is a restricted python execution environment,
if the variables are defined in the context of the expression they will be
found.
also using <dtml-call means you call the method without caring abouts it
return value, you probably want dtml-var like the following
<dtml-var expr="listPatient(_.None, _, pid=pid)">
hth
kapil