[Zope] Assign a value to a variable for use in different object

John Hunter jdhunter@ace.bsd.uchicago.edu
Mon, 13 May 2002 08:46:51 -0500


>>>>> "Leo" == Leo  <leochan@underwriting.ca> writes:

    Leo> Hello, One question I have during I'm creating my Zope
    Leo> pages. That's how can I use a value within the other
    Leo> object. I can assign a value to a variable within one object
    Leo> by using dtml-let. But how can I do that when use it in other
    Leo> object.  For example, I assign a value in a dtml method page
    Leo> and want to use the value in ZSQL method. Any way to do that?

One way to do it is to go to the ZSQL method in the Zope manager
interface and assign it 'Arguments', eg first_name, last_name

If you are in some DTML Document where first_name and last_name are
available, for example in the REQUEST variable from a form submission,
then you can just do:

<dtml-call my_method_sql>

And the variables will be passed automatically.

You can also pass the variables explicitly, as in this example, where
most of the variables are passed from the REQUEST.form header and
others are the return value of a python script add_to_filesystem_py

<dtml-call expr="add_eeg_sql( 
	pid=pid, 
	date=date, 
	filename=add_to_filesystem_py(folder_name='eegs', file_name=filename), 
	description=description,
	channels=channels,
	freq=freq,
	classification=classification,
	file_type=file_type,
	behavior_state=behavior_state,
	montage_file=add_to_filesystem_py('eegs', montage_file),
	mpg_file=add_to_filesystem_py('eegs', mpg_file)
	)"> 


As a final example, suppose the downstream object was a DTML method or
document, you can use the call syntax

# listPatients is a DTML Document with parameters 'sql', 'title' and
# 'noheader' 
<dtml-var expr="listPatients(_.None, _, sql='1 order by last',
	  title='The Great Seizure Database', noheader=1 )">


John Hunter