[Zope3-dev] Re: zope3 doesn't like the python datetime module?

Jim Fulton jim at zope.com
Tue Sep 23 10:23:39 EDT 2003


Anthony Baxter wrote:
>>>>"Tim Peters" wrote
>>
>>Actually, it looks more like this part of the Zope interface code breaks
>>when it's fed the C datetime types, yes?
> 
> 
> Yep, correct. It looks like you can't feed any C objects to 
> the interface code:

That's way to imprecise.  As I explained lesewhere.  You can't
declare instance-specific interfaces on immutable objects, which
includes C types.  Declaring the interfaces implemented by instances of
a C type works just fine.

...


> I haven't been able to find any code that asserts that a builtin object 
> implements an interface. You can "make it work" by subclassing the builtin
> type, like so:
> 
>>>>class dict1(dict):
> 
> ....   implements(I1
 >
 > but this is pretty horrible. It looks, to me, like this is just something
 > that the zope.interface package doesn't support... Jim?
 >
 > Anthony
 >


You don't need to subclass a builtin type to declare interfaces for it's
instances.

 >>> from zope.interface import *
 >>> class I(Interface):
...      pass
 >>> classImplements(dict, I)
 >> list(providedBy({}))
[<InterfaceClass __main__.I at 400e47ac>]

What you can't do is declare instance-specific interfaces (directlyProvides)
for immutable objects, such as built-in types.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list