Re: [Zope] renaming python input params in DTML

2001-01-15 Thread Dieter Maurer

Lee writes:
  ...
  I have a Python method expecting 'text' as a parameter ...
  ...
  The Python method, testSQL, returns 'result'.
  ...
  dtml-in expr="REQUEST.form.items()"
  dtml-in expr="testSQL(text='dtml-var sequence-keyxdtml-var
  sequence-item')"
  dtml-var result
  /dtml-in/dtml-in
Inside 'expr="..."' you use "_['x']" instead of dtml-var x.

As this is a Python expression that needs to be evaluated,
it cannot be in a string. You can use the "%" operator
which takes a format string and an object or tuple as
parameters and formats object/tuple according to the string.

If your Python method contains a "return result",
then there is not magically a "result" variable (and there is
not need for it, too).

Are you sure, you want the nested "dtml-in". Looks very strange.

Thus, you can use:

   dtml-in expr="REQUEST.form.items()"
 dtml-var expr="testSQL(text='%sx%s' % (_['sequence-key],_[' sequence-item]))"
   /dtml-in


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




RE: [Zope] renaming python input params in DTML

2001-01-14 Thread Randall F. Kern

You can't use DTML tags inside an expr="" attribute; the value of expr
is python code.

To access the sequence-item variable from python, you need:
_['sequence-item']

So, try something like this (untested):

dtml-in expr="REQUEST.form.items()"
dtml-in expr="testSQL(text=_['sequence-key'] + 'x' +
_['sequence-item'])"
dtml-var result
/dtml-in/dtml-in


-Randy

-Original Message-
From: Lee [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 14, 2001 1:23 PM
To: [EMAIL PROTECTED]
Subject: [Zope] renaming python input params in DTML


Hi,

I am having a problem passing in a variable to a Python method, which is
obtained from the REQUEST object - I'd really appreciate someone's
insight into how to correctly go about this.

I have a form that submits a parameter named '9728430xp0xclasstest' with
a value = 7 to a DTML method.

I have a Python method expecting 'text' as a parameter so I want the
DTML method to send 'text' onto this with a value = the value of the
original parameter appended to name (i.e. 9728430xp0xclasstestx7).

So text=9728430xp0xclasstestx7

Does that make sense?

The Python method, testSQL, returns 'result'. As I recently found out, I
have to make to make use of the REQUEST object to obtain these
parameters.

The following snippet produces the correct value
(9728430xp0xclasstestx7)...

dtml-in expr="REQUEST.form.items()"dtml-var sequence-keyxdtml-var
sequence-item/dtml-in

... but how can I can pass this as 'text' to my Python method?

Am I on the right track with the following:

dtml-in expr="REQUEST.form.items()"
dtml-in expr="testSQL(text='dtml-var sequence-keyxdtml-var
sequence-item')"
dtml-var result
/dtml-in/dtml-in

Thank very much for any help you can offer.

- Best regards,

PS:

dtml-let text="'9728430xp0xclasstestx7'"
dtml-var text
/dtml-let ... may help

but...

dtml-var standard_html_header
dtml-in expr="REQUEST.form.items()"
   dtml-let text="'dtml-var sequence-keyxdtml-var sequence-item'"
  dtml-var text
 /dtml-let
/dtml-in ... gives me text = x !

Any help would really be appreciated?

Thanks :)

--
Lee Reilly
mailto:[EMAIL PROTECTED]

````

HAVE SKILLS; WILL TRAVEL.

I'm currently looking for an internship in the USA
in the field of web development. Ideally, I'm looking
for a placement for 3 to 18 months. Can you help?

More details, my resume, etc. @
http://homepages.strath.ac.uk/~aeu97172/

/shameless plug




___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )