How to call a script by it's name stored in a variable.
How can I do something like this? var = '/Projects/test_py' return call_by_name(var) ------------------------------------ Thanks. -- View this message in context: http://www.nabble.com/How-to-call-a-script-by-it%27s-name-stored-in-a-variab... Sent from the Zope - General mailing list archive at Nabble.com.
rieh25 wrote:
How can I do something like this?
var = '/Projects/test_py'
return call_by_name(var)
------------------------------------ Thanks. fun = context.restrictedTraverse(var) return fun()
then there is path and getattr you should look at. robert
----- Original Message ----- From: "rieh25" <robertoedwins@gmail.com> To: <zope@zope.org> Sent: Tuesday, February 20, 2007 10:30 PM Subject: [Zope] How to call a script by it's name stored in a variable.
How can I do something like this?
var = '/Projects/test_py'
return call_by_name(var)
Another option: if the script you want to call is in the same folder as the calling script then this will work: var = 'test_py' return getattr(context, var)() Jonathan
participants (3)
-
Jonathan -
rieh25 -
robert rottermann