New restricted python - How to use in my Product?
Hi. In one of my products i use following code: import rexec r_env = rexec.RExec() selected=r_env.r_eval(self.default) that was zope 2.3 and python 2.0. With Zope 2.4.0 there is the new RestrictedPython module with this "expression" thing, but I can't find any useful documentation on how to use that. regards Christian -- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981 reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
Christian Theune wrote:
With Zope 2.4.0 there is the new RestrictedPython module with this "expression" thing, but I can't find any useful documentation on how to use that.
Check out the PythonExpr class in ZRPythonExpr.py of PageTemplates. It shows how to compile and evaluate an expression with Zope restrictions. Cheers, Evan @ 4-am & Zope
Hmm. I take a look and am a bit confused. With the old python (rexec) i had the possibility to have something evaluated fairly(?) secure within 3 lines. Now I shall create a THAT big class and environment to have a simple evaluation? Well, I don't need Zope restrictions nor enhancements. And I don't need to be in a Zope namespace. I just need to evaluate single, simple python statements like: None [1,2,3,4] 1 'asdf' Is there an easier way? Just using eval() is supposed to be unsecure. Thanks Christian On Mon, Jul 30, 2001 at 09:44:45AM -0400, Evan Simpson wrote:
Christian Theune wrote:
With Zope 2.4.0 there is the new RestrictedPython module with this "expression" thing, but I can't find any useful documentation on how to use that.
Check out the PythonExpr class in ZRPythonExpr.py of PageTemplates. It shows how to compile and evaluate an expression with Zope restrictions.
Cheers,
Evan @ 4-am & Zope
-- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981 reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
participants (2)
-
Christian Theune -
Evan Simpson