Allowing Regular expressions in Python Script
Hi, for using regular expressions in python script (import re ...) I used the explained method via a directory in lib/python/Products see
cat lib/python/Products/GlobalModules/__init__.py # Global module assertions for Python scripts from Products.PythonScripts.Utility import allow_module
allow_module('base64') allow_module('re') allow_module('time') I can use all time attributes and methods, but when I'm calling e.g. re.compile("a").match("ba", 1) in the script I get a authentification window from zope. This happens for different plattforms. Any idea what additional rights are necessary or whats happening at that point? Thanks -- Andreas Rippel Universität Kaiserslautern Fachbereich Informatik (AG ICSY) Tel: ++49 (0)631 205 3676 Paul Ehrlich Straße (G32/348) Fax: ++49 (0)631 205 3056 D-67653 Kaiserslautern (Germany) EMail: arippel@informatik.uni-kl.de PGP: http://www.icsy.de/~arippel/pgpkey.asc GNUPGP: .../gnukey.asc
Look in lib/python/Products/PythonScripts/module_access_examples.py Florent Andreas Rippel <arippel@informatik.uni-kl.de> wrote:
Hi,
for using regular expressions in python script (import re ...) I used the explained method via a directory in lib/python/Products see
cat lib/python/Products/GlobalModules/__init__.py # Global module assertions for Python scripts from Products.PythonScripts.Utility import allow_module
allow_module('base64') allow_module('re') allow_module('time')
I can use all time attributes and methods, but when I'm calling e.g. re.compile("a").match("ba", 1) in the script I get a authentification window from zope. This happens for different plattforms. Any idea what additional rights are necessary or whats happening at that point? -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
Andreas Rippel writes:
... allow_module('re') ... but when I'm calling e.g. re.compile("a").match("ba", 1) in the script I get a authentification window from zope. Regular expression objects and match objects are not itself complex instances that would need security declarations to be used in TTW code.
This is complicated because they are not (class) instances but instances of types defined in "C". You cannot assign the necessary security declarations directly. You would need to define wrappers that can carry the security declarations and delegate the requested operations. Dieter
I think it goes like this: from Products.PythonScripts.Utility import allow_module, allow_type import re allow_module('re') allow_type(type(re.compile(''))) allow_type(type(re.match('x','x'))) HTH, Stefan --On Mittwoch, 18. September 2002 12:54 +0200 Andreas Rippel <arippel@informatik.uni-kl.de> wrote:
Hi,
for using regular expressions in python script (import re ...) I used the explained method via a directory in lib/python/Products see
cat lib/python/Products/GlobalModules/__init__.py # Global module assertions for Python scripts from Products.PythonScripts.Utility import allow_module
allow_module('base64') allow_module('re') allow_module('time')
I can use all time attributes and methods, but when I'm calling e.g. re.compile("a").match("ba", 1) in the script I get a authentification window from zope. This happens for different plattforms. Any idea what additional rights are necessary or whats happening at that point?
-- Those who write software only for pay should go hurt some other field. /Erik Naggum/
participants (4)
-
Andreas Rippel -
Dieter Maurer -
Florent Guillaume -
Stefan H. Holek