[Zope] How do I use variable variables in pythonscript?

Jonothan Farr jfarr@real.com
Fri, 23 Feb 2001 14:07:30 -0800


Sounds like you want:

for action in things_to_do:
    func=getattr(context, action)
    func()

----- Original Message -----
From: <Jason.Jones@awl.com>
To: <zope@zope.org>
Sent: Friday, February 23, 2001 1:49 PM
Subject: [Zope] How do I use variable variables in pythonscript?


> I would like to do something like the following:
>
> <dtml-var "_[getform('do')]">
>
> where getform('do') returns the name of the method that is then called, but I
want to do it from a python script, that is, given a variable or a function, I
would like to evaluate what it stands for, for instance:
>
> for action in things_to_do:
>     context.action()
>
> where things_to_do is a list of names for method calls that I want to execute
in the python script's context.
>
> Is there a way to do this? What about something like the python script
equivalent of the dtml:
>
> <dtml-var "_[getform('do')+'_view']">
>
> Thanks,
>
> Jason
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> 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 )
>
>