Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Fred Drake
On 8/8/05, Gary Poster <[EMAIL PROTECTED]> wrote:
> I'm assuming you mean in Zope 3, rather than avoiding this
> possibility in Python, which seems like futile road.

Indeed, and in particular, I was referring to the import behavior
itself.  Your solution avoids the import quirkiness altogether, so it
much more reasonable.


  -Fred

-- 
Fred L. Drake, Jr.
Zope Corporation
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Gary Poster


On Aug 8, 2005, at 10:21 AM, Fred Drake wrote:


On 8/8/05, Gary Poster <[EMAIL PROTECTED]> wrote:


lol.  eek.  yuck. :-)



Yep.  Not sure what the best way to avoid this would be, either.


I'm assuming you mean in Zope 3, rather than avoiding this  
possibility in Python, which seems like futile road.


The relatively-quick-and-obvious-to-me-but-not-necessarily-correct  
solution would be to


- make the zope.security.checker._available_by_default data structure  
rebuild itself the same way that the _checkers data structure resets  
in _clear;


- add an API to add a name in zope.security.checker, parallel to  
defineChecker


- make yet-another-zcml-directive to set the name, and use it in  
zope.app.security.


- delete _protections.py and all references to it.

Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Fred Drake
On 8/8/05, Gary Poster <[EMAIL PROTECTED]> wrote:
> lol.  eek.  yuck. :-)

Yep.  Not sure what the best way to avoid this would be, either.


  -Fred

-- 
Fred L. Drake, Jr.
Zope Corporation
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Fred Drake
On 8/8/05, Fred Drake <[EMAIL PROTECTED]> wrote:
> On 8/8/05, Gary Poster <[EMAIL PROTECTED]> wrote:
> > Right.  As I perhaps only hinted in the proposal, it is impossible to
> > import _protections from zope.app.security, because of this in the
> > __init__:
> >
> > import _protections
> > _protections.protect()
> > del _protections
> 
> Depends on how you spell the import, unfortunately:
> 
> >>> import zope.app.security._protections
> >>> zope.app.security._protections
> Traceback (most recent call last):
>   File "", line 1, in ?
> ImportError: cannot import name _protections

Argh, that's a copy/paste error.  Try this:

>>> import zope.app.security._protections
>>> from zope.app.security import _protections
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: cannot import name _protections

>>> zope.app.security._protections
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute '_protections'

>>> from zope.app.security._protections import protect
>>> protect



  -Fred

-- 
Fred L. Drake, Jr.
Zope Corporation
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Gary Poster


On Aug 8, 2005, at 10:15 AM, Fred Drake wrote:


On 8/8/05, Gary Poster <[EMAIL PROTECTED]> wrote:


Right.  As I perhaps only hinted in the proposal, it is impossible to
import _protections from zope.app.security, because of this in the
__init__:

import _protections
_protections.protect()
del _protections



Depends on how you spell the import, unfortunately:



import zope.app.security._protections
zope.app.security._protections


Traceback (most recent call last):
  File "", line 1, in ?
ImportError: cannot import name _protections



from zope.app.security._protections import protect
protect





lol.  eek.  yuck. :-)

Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Fred Drake
On 8/8/05, Gary Poster <[EMAIL PROTECTED]> wrote:
> Right.  As I perhaps only hinted in the proposal, it is impossible to
> import _protections from zope.app.security, because of this in the
> __init__:
> 
> import _protections
> _protections.protect()
> del _protections

Depends on how you spell the import, unfortunately:

>>> import zope.app.security._protections
>>> zope.app.security._protections
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: cannot import name _protections

>>> from zope.app.security._protections import protect
>>> protect



  -Fred

-- 
Fred L. Drake, Jr.
Zope Corporation
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Gary Poster


On Aug 8, 2005, at 9:51 AM, Philipp von Weitershausen wrote:


[SNIP] This might have not worked anyway [SNIP]


Right.  As I perhaps only hinted in the proposal, it is impossible to  
import _protections from zope.app.security, because of this in the  
__init__:


import _protections
_protections.protect()
del _protections

After the del from the __init__, you can no longer import it AFAICT.

Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Philipp von Weitershausen
Fred Drake wrote:
> On 8/8/05, Philipp von Weitershausen <[EMAIL PROTECTED]> wrote:
> 
>>For compatability reasons, zope.app.security._protections and the
>>protect() function inside (though empty) should probably still exist for
>>at least another release because people might be using it in their own
>>tests (even though it's not public API). A deprecation warning could
> 
> 
> I disagree that we should be worried about people using that function
> directly; we've been much better in separating public API and
> implmentation detail in Zope 3.  Anything in a module with a name
> starting with an underscore is fair game.
> 
> I would, however, be more concerned about things that happen as a side
> effect of importing a package.  That's pretty magical and is not
> something many are likely to be watching out for.  I'm not suggesting
> that it's sufficient to require us to keep the behavior around; this
> is still an implementation detail within the zope.app hierarchy IMO.

In general I agree, but I was concerned about people using this
particular underscore function because it was their only way to get the
protections right in tests. This might have not worked anyway in which
case we can scrap it.

Either way, I don't feel strongly about this. Go ahead and remove the
sucker :).

Philipp
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: Problem with zope.app.security._protections for tests

2005-08-08 Thread Fred Drake
On 8/8/05, Philipp von Weitershausen <[EMAIL PROTECTED]> wrote:
> For compatability reasons, zope.app.security._protections and the
> protect() function inside (though empty) should probably still exist for
> at least another release because people might be using it in their own
> tests (even though it's not public API). A deprecation warning could

I disagree that we should be worried about people using that function
directly; we've been much better in separating public API and
implmentation detail in Zope 3.  Anything in a module with a name
starting with an underscore is fair game.

I would, however, be more concerned about things that happen as a side
effect of importing a package.  That's pretty magical and is not
something many are likely to be watching out for.  I'm not suggesting
that it's sufficient to require us to keep the behavior around; this
is still an implementation detail within the zope.app hierarchy IMO.

> Ok. Maybe there should be a collector issue about this so that we
> remember it for upcoming releases.

Agreed.


  -Fred

-- 
Fred L. Drake, Jr.
Zope Corporation
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com