parameters from dtml to python
I have an external method(python): def makePhoneList(searchString, *sortBy): Then I want to be able to call it in a dtml-document like so (wrong, I know, but to illustrate what I am looing for). <dtml-in expr="makePhoneList(searchString='foo', '<dtml-var sortBy1>', '<dtml-var sortBy2>')"> The sortBy1 and sortBy2 are variables in the DTML-document. But I am having problems with the arguments. Possibly due to the fact that my function specifies *sortBy as a list of parameters. Any suggestions would be appreciated. Jorg Rødsjø EDB-HF NTNU
Hello Jorg, Monday, November 18, 2002, 2:35:54 PM, you wrote:
I have an external method(python): def makePhoneList(searchString, *sortBy): Then I want to be able to call it in a dtml-document like so (wrong, I know, but to illustrate what I am looing for). <dtml-in expr="makePhoneList(searchString='foo', '<dtml-var sortBy1>', '<dtml-var sortBy2>')"> The sortBy1 and sortBy2 are variables in the DTML-document.
you cannot nest dtml-tags: <dtml-in expr="makePhoneList('foo', [sortBy1, sortBy2])"> could work , depending on what you are trying to accomplish.. inside expr="" you do simple python, not DTML :) -- Geir Bækholt geir@funcom.com Tools/HCI-developer Tools/Billing - Product Operations Funcom Oslo
* Geir Bækholt <geirh@funcom.com>
Hello Jorg,
you cannot nest dtml-tags: <dtml-in expr="makePhoneList('foo', [sortBy1, sortBy2])"> could work , depending on what you are trying to accomplish..
inside expr="" you do simple python, not DTML :)
That is what I was afraid of. Is there (forgetting the *args problem) to pass variables from a dtml-document to the script? -jorg EDB-HF NTNU
on or about, Monday, November 18, 2002, we have reason to believe that Jorg E. Rødsjø wrote something along the lines of :
you cannot nest dtml-tags:
JER> That is what I was afraid of. Is there (forgetting the *args problem) to JER> pass variables from a dtml-document to the script? <dtml-in expr="makePhoneList(var1, var2)"> just use them directly. You are in python-space now, no need to encapsulate them in dtml-tags... :) -- Geir Bækholt geir@funcom.com Tools/HCI-developer Tools/Billing - Product Operations Funcom Oslo
Jorg E. Rødsjø writes:
I have an external method(python):
def makePhoneList(searchString, *sortBy):
Then I want to be able to call it in a dtml-document like so (wrong, I know, but to illustrate what I am looing for).
<dtml-in expr="makePhoneList(searchString='foo', '<dtml-var sortBy1>', '<dtml-var sortBy2>')">
The sortBy1 and sortBy2 are variables in the DTML-document.
<dtml-in expr="makePhoneList(searchString='foo', sortBy1, sortBy2)"> will be fine.
But I am having problems with the arguments. Possibly due to the fact that my function specifies *sortBy as a list of parameters. Probably not.
"*sortBy" in your function definition accepts a (potentially empty) sequence of values. "sortBy" is a tuple in your function.
Any suggestions would be appreciated. You, probably, should think about some background reading (Zope Book, Python documentation).
Dieter
On Monday, November 18, 2002, at 01:35 PM, Jorg E. Rødsjø wrote:
<dtml-in expr="makePhoneList(searchString='foo', '<dtml-var sortBy1>', '<dtml-var sortBy2>')">
..the above can't work because you can't have DTML within DTML. You need to get the difference between DTML-space and python-space. They are kind of separate but can be made to know about each other quite easily like this... <!-- this lets python know about the variables --> <dtml-let s1=sortBy1 s2=sortBy2> <!-- note I've named the params (seems to help) --> <dtml-in "makePhoneList(searchString=searchString, sortBy1=s1, sortBy2=s2 )"> <dtml-var firstName><br/> </dtml-in> </dtml-let> cheers tom -- tom smith http://www.othermedia.com/blog/ 0207 089 5959 3rd Floor, The Pavilion, Newham's Row, London SE1 3UZ
* tom smith <tom@othermedia.com>
..the above can't work because you can't have DTML within DTML.
You need to get the difference between DTML-space and python-space. They are kind of separate but can be made to know about each other quite easily like this...
Thanks for the help. After a little fidgeting things are woriking fine. -jorg -- Jorg E. Rødsjø "And the dirt still stains me. elsewhere.dhs.org So wash me until I am clean."
participants (5)
-
Dieter Maurer -
Geir Bækholt -
Geir B�kholt -
Jorg E. Rødsjø -
tom smith