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

Anthony Baxter anthony at interlink.com.au
Sun Sep 21 22:00:26 EDT 2003


>>> "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:

>>> from zope.interface import Interface, directlyProvides
>>> class I1(Interface): pass
... 
>>> 
>>> directlyProvides(dict, I1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/anthony/src/zope/Zope3Head/src/zope/interface/declarations.py", line 969, in directlyProvides
    object.__provides__ = ProvidesSpecification(*interfaces)
TypeError: can't set attributes of built-in/extension type 'dict'

It looks like the interface package sets a magic __provides__ attribute
to specify the interfaces. This breaks with C types (pity Guido fixed
the object.__setattr__ hole ;)

> Yup.  Offhand I don't know what causes the problem.  I would *like* to see
> Zope Corp require Python 2.3 for Zope3.  That would force the issue in such
> a way that it must be solved.  

I'd be +1 on that - 2.3 has proven to be remarkably solid - the lack of any
critical patches in 2.3.1 is testament to that.

To put it another way, is there any real good reason to continue to support
2.2 over 2.3? It's not like there's a supported base of 2.2-Zope3 installations.

> So long as we dilute our efforts wrestling
> with artificial Python 2.2 compatibility requirements too, I doubt that this
> one is going to make it to the top of my todo list (it can rise to crisis
> status so long as "use the Python implementation" remains a blessed
> alternative).

So if I break the python version, will that help? <wink>

> BTW, it's generally true that you can't set attributes on an object of a
> builtin type (the datetime types aren't unique that way), so if you want to
> pursue this now I'd look for code that manages to use, e.g., dicts with
> interfaces now.

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

-- 
Anthony Baxter     <anthony at interlink.com.au>   
It's never too late to have a happy childhood.




More information about the Zope3-dev mailing list