[Zope-Coders] Re: [Zope-Checkins] CVS: Zope/lib/python/AccessControl - ZopeGuards.py:1.13

Chris Withers chrisw@nipltd.com
Wed, 18 Dec 2002 15:57:54 +0000


Shane Hathaway wrote:
>> How so? The idea I was suggesting should let you hot-replace the bits 
>> that you would otherwise have to put into the core...
> 
> I don't see what you mean.  The name "TransparentFolder" should not 
> appear anywhere in Zope, so what would I do?

Why would it? The code which would do the hotpatchign would only reside in your 
product. Then again, maybe I'm misunderstanding how the PluginIndexes 
shenanigans works, and I certainyl don't know anything about what 
TransparentFolder needs to alter.

>>> imp.find_module() doesn't seem to do enough: it can't deal with 
>>> hierarchical names until you load_module().
>>
>> Well, you wouldn't use find_module, just load_module. And I'm counting 
>> on that not to do anything with heirarchical names so that we don't 
>> import anything we're not planning on importing...
> 
> load_module executes the module, just like __import__.  Maybe I don't 
> understand what you're saying.

Use load_module to _only_ import the zope_security module IFF it can be found by 
find_module. Sicne we know where we're starting from, would it matter that the 
dotted name isn't used?

I dunno, maybe the manual searching thing is easier :-(

>> How about just raise a HideousSecurityHole exception? ;-)
> 
> I'm concerned that some versions of Python (perhaps unreleased versions) 
> may catch that exception and transform it into ImportError.  I don't 
> know how likely that is, though.

Good call. Marker attribute it is then...

>> They'll be ImportErrors, and I'll be doing an assertRaises.
> 
> What happens now when you try to import something not specifically 
> allowed?  ImportError or Unauthorized?  

An Unauthorized is raised, which is then caught and turned into an ImportError, 
so it's always an ImportError that ends up coming back...

cheers,

Chris