[Zope-dev] urllib not available in Python Scripts?

Itai Tavor itai@optusnet.com.au
Mon, 18 Dec 2000 10:41:58 +1100


Evan Simpson wrote:

>From: "Itai Tavor" <itai@optusnet.com.au>
>>  The reason I could do urllib.quote in Python Methods was that I
>>  implemented the MoreBuiltins trick someone described here a while
>>  ago.
>
>That would be me :-)

Ok ,then, thank you for it :-)


>  > Is there anything that can be done so that adding modules continues
>>  to work?
>
>Sure.  Since you've already got a MoreBuiltins module, that's probably a
>fine place to put this.  In MoreBuiltins/__init__.py (or a brand new Product
>directory of your choice) put the following lines:
>
>   import urllib
>   urllib.__allow_access_to_unprotected_subobjects__ = 1
>
>...and similarly if you want to declare other modules PS-importable.  As of
>2.3, the proper way to do this will be:
>
>   from AccessControl import ModuleSecurityInfo
>   ModuleSecurityInfo('urllib').setDefaultAccess(1)

Ok, this is simple enough, and it works. But... it opens access to 
everything in urllib. I played around a bit and found that I can't do 
any harm with urlopen because I still don't have access to URLopener 
objects. But urlretrieve does work, and I can imagine being able to 
do some damage with it. MoreBuiltins selected a subset of urllib 
methods to make available for Python Methods - can that be done for 
Python Scripts?
-- 
Itai Tavor                    "Je sautille, donc je suis."
C3Works    itai@c3works.com              - Kermit the Frog

"If you haven't got your health, you haven't got anything"