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? Thanks John Hunter
[John Hunter]>
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?
Once you are within a dtml tag, you do not need to nest dtml tags, you just refer to things by their names, as in <dtml-call expr="listPatient( pid=pi)" > This can be simplified to <dtml-call "listPatient(pid=pi)"> Of course, "pi" has to be a variable known to the page containing the code. Try to keep things simple whenever you can. Cheers, Tom P
And... I'm 47% sure that you really mean <dtml-var "listPatient(pid=pi)"> -steve On Thursday, February 14, 2002, at 10:56 AM, Thomas B. Passin wrote:
This can be simplified to
<dtml-call "listPatient(pid=pi)">
Of course, "pi" has to be a variable known to the page containing the code.
[Steve Spicklemire]
And... I'm 47% sure that you really mean
<dtml-var "listPatient(pid=pi)">
-steve
On Thursday, February 14, 2002, at 10:56 AM, Thomas B. Passin wrote:
This can be simplified to
<dtml-call "listPatient(pid=pi)">
Of course, "pi" has to be a variable known to the page containing the code.
Could be ... I thought the original question had dtml-call, so I copied that, not knowing how it would be used... Tom P
John Hunter writes:
... DTML object "listPatient" ... <dtml-call expr="listPatient( 'pid=%s' % <dtml-var pid>)" > You already have been told to use "pid" rather than "<dtml-var pid>".
Please also read the section "Calling DTML objects" in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Otherwise, I expect, you will get "NameError" or "KeyError" exceptions from "listPatient" because called the way it is above, it has not context and cannot find surrounding Zope objects... Dieter
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
participants (5)
-
Dieter Maurer -
John Hunter -
kapil thangavelu -
Steve Spicklemire -
Thomas B. Passin