[Zope-dev] Acquisition wrapped objects do not behave well on unicode call

Michael Howitz mh at gocept.com
Tue Feb 15 08:35:32 EST 2011


Hi,

When I have an acquisition wrapped object, e. g. my_object and call:

>>> unicode(my_object)

The method __str__ of my_object is called even when it has an __unicode__ method.

See the following bin/zopectl debug session:

$ bin/zinstance debug
Starting debugger (the name "app" is bound to the top-level Zope object)
>>> import OFS.SimpleItem
>>> class A(OFS.SimpleItem.SimpleItem):
... def __str__(self): return '__str__ called'
... def __unicode__(self): return '__unicode__ called'
...
>>> a = A()
>>> print unicode(a)
__unicode__ called
>>> print unicode(a.__of__(app))
__str__ called
>>> print type(a.__of__(app))
<type 'Acquisition.ImplicitAcquisitionWrapper'>

This happens for Python 2.6 and 2.7 on Zope 2.13.4.

Is there a suggested work around?

P.S.: I also filed a bug report: https://bugs.launchpad.net/acquisition/+bug/719335 


Yours sincerely,
-- 
Michael Howitz · mh at gocept.com · software developer
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 8 · fax +49 345 1229889 1
Zope and Plone consulting and development



More information about the Zope-Dev mailing list