Re: [Zope3-dev] Proxy and __slots__

2005-08-29 Thread Jim Fulton

Garrett Smith wrote:

I'd like to create a proxy where __slots__ is determined (or appended to) when 
the proxy is constructed. E.g.



foo = Foo()
bar = SomeProxy(foo, 'baz')
bar.baz = 123
hasattr(foo, 'baz')


False


hasattr(bar, 'baz')


True

Is it possible to do this?


No, at least not using the standard __slot__ mechanism.

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



RE: [Zope3-dev] Proxy and __slots__

2005-08-29 Thread Garrett Smith
I ended up using 'type' to create a new proxy with a dynamically created 
__slots__. I haven't run into any weirdness with that approach, so far :)

 -- Garrett

 -Original Message-
 From: Jim Fulton [mailto:[EMAIL PROTECTED] 
 Sent: Monday, August 29, 2005 9:03 AM
 To: Garrett Smith
 Cc: 'zope3-dev@zope.org'
 Subject: Re: [Zope3-dev] Proxy and __slots__
 
 Garrett Smith wrote:
  I'd like to create a proxy where __slots__ is determined 
 (or appended to) when the proxy is constructed. E.g.
  
  
 foo = Foo()
 bar = SomeProxy(foo, 'baz')
 bar.baz = 123
 hasattr(foo, 'baz')
  
  False
  
 hasattr(bar, 'baz')
  
  True
  
  Is it possible to do this?
 
 No, at least not using the standard __slot__ mechanism.
 
 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