Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

dynamically call zsqlmethod

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


garry at schoolteachers

Nov 25, 2009, 10:53 AM

Post #1 of 4 (1219 views)
Permalink
dynamically call zsqlmethod

I am passing a variable named 'column' to the following script and
trying to fill a select box with the result of a zsqlmethod chosen
dynamically using this variable.

print """<select name="nonboolean" method="post">"""
command=context.column()

for row in command:
code=row.code
meaning=row.meaning
print """<option value="%s">%s</option>""" &(code,meaning)

print """</select>"""
return printed



I can not work out how to substitiute the command with the variable, any
help much appreciated.
Regards
Garry
_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )


lists at zopyx

Nov 25, 2009, 10:56 AM

Post #2 of 4 (1137 views)
Permalink
Re: dynamically call zsqlmethod [In reply to]

getattr(context, column)()?

-aj

On Wed, Nov 25, 2009 at 19:53, Garry Saddington
<garry [at] schoolteachers>wrote:

> I am passing a variable named 'column' to the following script and
> trying to fill a select box with the result of a zsqlmethod chosen
> dynamically using this variable.
>
> print """<select name="nonboolean" method="post">"""
> command=context.column()
>
> for row in command:
> code=row.code
> meaning=row.meaning
> print """<option value="%s">%s</option>""" &(code,meaning)
>
> print """</select>"""
> return printed
>
>
>
> I can not work out how to substitiute the command with the variable, any
> help much appreciated.
> Regards
> Garry
> _______________________________________________
> Zope maillist - Zope [at] zope
> https://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope-dev )
>


jeff.peterson at crary

Nov 25, 2009, 11:30 AM

Post #3 of 4 (1134 views)
Permalink
Re: dynamically call zsqlmethod [In reply to]

IF it's a variable passed to the script wouldn't you simply access it as 'column'?

Also, is it a variable or a function? Or is the variable the name of a function somewhere?

If it's the former just call it: column().

If it's the latter, Andreas should be correct, getattr(context, column)() or possible context[column] if you like that better.

--
Jeffrey D Peterson
Webmaster
Crary Industries, Inc.


-----Original Message-----
From: zope-bounces [at] zope [mailto:zope-bounces [at] zope] On Behalf Of Garry Saddington
Sent: Wednesday, November 25, 2009 12:53 PM
To: zope [at] zope
Subject: [Zope] dynamically call zsqlmethod

I am passing a variable named 'column' to the following script and
trying to fill a select box with the result of a zsqlmethod chosen
dynamically using this variable.

print """<select name="nonboolean" method="post">"""
command=context.column()

for row in command:
code=row.code
meaning=row.meaning
print """<option value="%s">%s</option>""" &(code,meaning)

print """</select>"""
return printed



I can not work out how to substitiute the command with the variable, any
help much appreciated.
Regards
Garry
_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )


garry at schoolteachers

Nov 25, 2009, 12:32 PM

Post #4 of 4 (1128 views)
Permalink
Re: dynamically call zsqlmethod [In reply to]

Jeff Peterson wrote:
> IF it's a variable passed to the script wouldn't you simply access it as 'column'?
>
> Also, is it a variable or a function? Or is the variable the name of a function somewhere?
>
> If it's the former just call it: column().
>
> If it's the latter, Andreas should be correct, getattr(context, column)() or possible context[column] if you like that better.
Thanks, Andreas' solution works for me.
Regards
Garry
_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.