[Zope] Evaluating python with my own variable bindings

Ross Boylan RossBoylan@stanfordalumni.org
Mon, 5 Aug 2002 14:41:24 -0700


I would like to bind symbols to values, e.g, Q1=True, Q2=False.... and
then allow the user to specify arbitary logical expressions like
Q3 and Q4

or (given different bindings)
Q2 == 5

It would be fine if they could execute arbitrary python scraps.

It looks to me as if this might be a job for a PythonScript.  I was
going to evaluate an arbitrary string, but since PythonScript has a
security and binding framework it seems better to use it.  So I
have two questions:

1) Is PythonScript the most appropriate tool?
In particular, I am concerned because I am not calling it from the
web, but from some code in my product.  The API reference does not
refer to this case as a possible use.

2) Exactly how do I bind the symbols for use within the script?


In case you are wondering, I'm doing this for rules like "only
answer question 5 if you said yes to questions 3 or 4".

Thanks.