Chris Withers <chrisw@nipltd.com> wrote:
Terry Kerr wrote:
Hi,
Is there any way to get access to inbuild python functions like 'filter' and 'lambda' within pythonMethods?
I think the powers that be decided they were 'unsafe' :-(
Can anyone confirm or deny?
'lambda' is actually a keyword, not a function, and hence works fine in PM0.1.7. 'map()', 'filter()', et al., were deemed to be susceptible to being used in DOS attacks, and hence are not permitted in through-the-web code (they would need to be added to the '_' namespace, like 'str()', et aliae). Tres. -- =============================================================== Tres Seaver tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org
* Tres Seaver (tseaver@digicool.com) [001130 09:06]:
Chris Withers <chrisw@nipltd.com> wrote: 'lambda' is actually a keyword, not a function, and hence works fine in PM0.1.7. 'map()', 'filter()', et al., were deemed to be susceptible to being used in DOS attacks, and hence are not permitted in through-the-web code (they would need to be added to the '_' namespace, like 'str()', et aliae).
For those of us who are trying to figure out everything at a low level, where would this be in the source? Ciao! -- When a trainstation is were a train stops what is a workstation? The Doctor What: Un-Humble http://docwhat.gerf.org/ docwhat@gerf.org KF6VNC
From: The Doctor What <docwhat@gerf.org>
For those of us who are trying to figure out everything at a low level, where would this be in the source?
Here's an example of adding stuff to '_' using a monkey patch Product. Contents of __init__.py of directory Products/MoreBuiltins: def _AddBuiltins(): from urllib import urlopen, quote, unquote from base64 import decodestring, encodestring def same_type(self, a, b): return type(a)==type(b) def attr_map(self, o): r = o.__dict__.copy() for k in r.keys(): if k[:1] == '_': del r[k] return r class AnObject: def __init__(self, **kw): self.__dict__.update(kw) NewBuiltins = { 'list': list, 'tuple': tuple, 'map': map, 'filter': filter, 'reduce': reduce, 'urllib': AnObject(open=urlopen, quote=quote, unquote=unquote), 'base64': AnObject(decode=decodestring, encode=encodestring), 'same_type': same_type, 'attr_map': attr_map, } from DocumentTemplate.DT_Util import TemplateDict TemplateDict.__dict__.update(NewBuiltins) #call it _AddBuiltins()
participants (3)
-
Evan Simpson -
The Doctor What -
Tres Seaver