[Zope3-dev] Security Proxy/isinstance

2005-12-02 Thread Andres Freund

Hi,

I'm working with the combination of Zope3 and sqlobjet over sqlos and 
discovered a problem (about SecurityProxy as i already asked about in 
#zope3-dev).


Some code in sqlobject is using isinstance() to decide what to do. The 
problem is, that sometimes sqlobject gets securityProxied objects from 
Zope, which theoretically is no problem. But in praxis it uses 
isinstance and the SecurityProxy doesn't cooperate with that.


Now i searched a bit in the web and discovered, that according to this: 
http://mail.python.org/pipermail/python-bugs-list/2003-February/016098.html 
it should be possible to make the Proxies a bit more transparent.


Did i understand that correctly? I dont understand to much about python 
and especially about zope, but i think, that should be the way to go, or 
am i mistaken?


After a short look at _zope_proxy_proxy.c i think that this shouldn't be 
too hard to implement (although i never touched the python c bindings 
before, so it not unlikely that I'm mistaken).


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



Re: [Zope3-dev] Security Proxy/isinstance

2005-12-02 Thread Dominik Huber

Andres Freund wrote:


Hi,

I'm working with the combination of Zope3 and sqlobjet over sqlos and 
discovered a problem (about SecurityProxy as i already asked about in 
#zope3-dev).


Some code in sqlobject is using isinstance() to decide what to do. The 
problem is, that sometimes sqlobject gets securityProxied objects from 
Zope, which theoretically is no problem. But in praxis it uses 
isinstance and the SecurityProxy doesn't cooperate with that.


Now i searched a bit in the web and discovered, that according to 
this: 
http://mail.python.org/pipermail/python-bugs-list/2003-February/016098.html 
it should be possible to make the Proxies a bit more transparent.


Did i understand that correctly? I dont understand to much about 
python and especially about zope, but i think, that should be the way 
to go, or am i mistaken?


After a short look at _zope_proxy_proxy.c i think that this shouldn't 
be too hard to implement (although i never touched the python c 
bindings before, so it not unlikely that I'm mistaken).


You can use zapi.isinstance (zope.security.proxy orig. place). This 
function is useful because it works even if the instance is security 
proxied.


Regards,
Dominik
begin:vcard
fn:Dominik Huber
n:Huber;Dominik
email;internet:[EMAIL PROTECTED]
tel;work:++41 56 534 77 30
x-mozilla-html:FALSE
version:2.1
end:vcard

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



Re: [Zope3-dev] Security Proxy/isinstance

2005-12-02 Thread Andres Freund

Hi,

Dominik Huber wrote:
You can use zapi.isinstance (zope.security.proxy orig. place). This 
function is useful because it works even if the instance is security 
proxied.

I know that from irc but there are two issues:
-Fixing that in foreign code is dirty and error prone. In my own code i 
wouldn't have a problem with it.


-Why not fix it in the proxies if the problem can be solved? Thats the 
way much more clean way i think. You don't want to learn new ways, if 
the old ones can be made compatible.


For now i fixed that through monkey patching, but i don't like that.


Andres Freund

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



Re: [Zope3-dev] Security Proxy/isinstance

2005-12-02 Thread Jim Fulton

Andres Freund wrote:

Hi,

Dominik Huber wrote:

You can use zapi.isinstance (zope.security.proxy orig. place). This 
function is useful because it works even if the instance is security 
proxied.


I know that from irc but there are two issues:
-Fixing that in foreign code is dirty and error prone. In my own code i 
wouldn't have a problem with it.


-Why not fix it in the proxies if the problem can be solved? Thats the 
way much more clean way i think. You don't want to learn new ways, if 
the old ones can be made compatible.


For now i fixed that through monkey patching, but i don't like that.


This can't be fixed by changing the proxy behavior.  Security proxies
expose a valid __class__ attribute except that it is security proxied.
It isn't valid to change this.  Unfortunately, the standard Python isinstance
requires that the value if the __class__ attribute is a known class
type.  It does this because it uses internal C data structures of types
which it can't get to through a proxy.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] Re: zope.configuration and ImportErrors

2005-12-02 Thread Florent Guillaume

Rocky Burt wrote:
Today it's very hard to debug ImportErrors raise inside modules  
referenced through a zcml directive, because the ImportError is  
swallowed an no traceback comes back to the user. Just a
  ConfigurationError: ('Invalid value for', 'class', Couldn't  import 
some.class, cannot import name somename)

which doesn't point anywhere useful.

I'd like to modify zope.configuration.config to something like:

try:
mod = __import__(mname, *_import_chickens)
except ImportError, v:
+if sys.exc_info()[2].tb_next is not None:
+# ImportError was caused deeper
+raise
raise ConfigurationError, (
Couldn't import %s, %s % (mname, v)
), sys.exc_info()[2]



+1 for any fix.

+1 for this fix :)


Ok I'll try to check this in during the weekend.

Florent

--
Florent Guillaume, Nuxeo (Paris, France)   Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com