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

2011-03-01 Thread Christian Zagrodnick
On 2011-02-28 07:43:55 +0100, Christian Zagrodnick said:

 On 2011-02-25 21:56:49 +0100, David Glick said:
 
 On 2/20/11 1:32 AM, Christian Zagrodnick wrote:
 On 2011-02-19 17:17:44 +0100, Hanno Schlichting said:
 
 On Thu, Feb 17, 2011 at 8:27 AM, Christian Zagrodnickc...@gocept.com  
 wrote:
 On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called
Sure.
I'll 
 
 review, merge and release. Should be sometime this week,
 cannot promise a day.
 Branch reviewed, merged and released in Acquisition 2.13.6.
 
 Could you remove the merged branch once you updated your buildout config?
 Done.
 
 Thanks for releasing!
 This change introduces a regression when calling unicode on wrapped
 objects that implement __str__ but not __unicode__. Essentially it is
 now doing the equivalent of str(aq_base(obj)) ... __str__ used to get a
 wrapped object as 'self', but now it is unwrapped.
 
 Here's a failing test that can be added to Acquisition's TestUnicode
 test case to demonstrate the issue:
 
 def test_str_fallback_is_still_wrapped(self):
 class A(Acquisition.Implicit):
 def __str__(self):
 return str(len(Acquisition.aq_chain(self)))
 wrapped = A().__of__(A())
 self.assertEqual(u'2', unicode(wrapped))
 
 This is currently causing some regressions in Plone tests.
 
 I'll have a look at it. Thanks for spotting that.

Fixed in r120651 (trunk)

- Fixed bug: When an object did not implement ``__unicode__``, calling
  ``unicode(wrapped)`` was calling ``__str__`` with an unwrapped ``self``.

Is the situation with Plone better now?


-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-03-01 Thread David Glick
On 3/1/11 11:57 AM, Christian Zagrodnick wrote:
 This change introduces a regression when calling unicode on wrapped
 objects that implement __str__ but not __unicode__. Essentially it is
 now doing the equivalent of str(aq_base(obj)) ... __str__ used to get a
 wrapped object as 'self', but now it is unwrapped.

 Here's a failing test that can be added to Acquisition's TestUnicode
 test case to demonstrate the issue:

 def test_str_fallback_is_still_wrapped(self):
 class A(Acquisition.Implicit):
 def __str__(self):
 return str(len(Acquisition.aq_chain(self)))
 wrapped = A().__of__(A())
 self.assertEqual(u'2', unicode(wrapped))

 This is currently causing some regressions in Plone tests.
 I'll have a look at it. Thanks for spotting that.
 Fixed in r120651 (trunk)

 - Fixed bug: When an object did not implement ``__unicode__``, calling
``unicode(wrapped)`` was calling ``__str__`` with an unwrapped ``self``.

 Is the situation with Plone better now?

Yes, this fixes the test failures we were seeing before. Thanks!
David


--  
David Glick
 Web Developer
 davidgl...@groundwire.org
 206.286.1235x32

Groundwire: You Are Connected   
 http://groundwire.org  

Online tools and strategies for the environmental movement.  Sign up for 
Groundwire News!
 http://groundwire.org/email-capture


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-27 Thread Christian Zagrodnick
On 2011-02-25 21:56:49 +0100, David Glick said:

 On 2/20/11 1:32 AM, Christian Zagrodnick wrote:
 On 2011-02-19 17:17:44 +0100, Hanno Schlichting said:
 
 On Thu, Feb 17, 2011 at 8:27 AM, Christian Zagrodnickc...@gocept.com  
 wrote:
 On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called
Sure.
I'll 
 
 review, merge and release. Should be sometime this week,
 cannot promise a day.
 Branch reviewed, merged and released in Acquisition 2.13.6.
 
 Could you remove the merged branch once you updated your buildout config?
 Done.
 
 Thanks for releasing!
 This change introduces a regression when calling unicode on wrapped
 objects that implement __str__ but not __unicode__. Essentially it is
 now doing the equivalent of str(aq_base(obj)) ... __str__ used to get a
 wrapped object as 'self', but now it is unwrapped.
 
 Here's a failing test that can be added to Acquisition's TestUnicode
 test case to demonstrate the issue:
 
  def test_str_fallback_is_still_wrapped(self):
  class A(Acquisition.Implicit):
  def __str__(self):
  return str(len(Acquisition.aq_chain(self)))
  wrapped = A().__of__(A())
  self.assertEqual(u'2', unicode(wrapped))
 
 This is currently causing some regressions in Plone tests.

I'll have a look at it. Thanks for spotting that.


-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-25 Thread David Glick
On 2/20/11 1:32 AM, Christian Zagrodnick wrote:
 On 2011-02-19 17:17:44 +0100, Hanno Schlichting said:

 On Thu, Feb 17, 2011 at 8:27 AM, Christian Zagrodnickc...@gocept.com  
 wrote:
 On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called
 Sure.
 I'll review, merge and release. Should be sometime this week,
 cannot promise a day.
 Branch reviewed, merged and released in Acquisition 2.13.6.

 Could you remove the merged branch once you updated your buildout config?
 Done.

 Thanks for releasing!
This change introduces a regression when calling unicode on wrapped 
objects that implement __str__ but not __unicode__. Essentially it is 
now doing the equivalent of str(aq_base(obj)) ... __str__ used to get a 
wrapped object as 'self', but now it is unwrapped.

Here's a failing test that can be added to Acquisition's TestUnicode 
test case to demonstrate the issue:

 def test_str_fallback_is_still_wrapped(self):
 class A(Acquisition.Implicit):
 def __str__(self):
 return str(len(Acquisition.aq_chain(self)))
 wrapped = A().__of__(A())
 self.assertEqual(u'2', unicode(wrapped))

This is currently causing some regressions in Plone tests.

David


--  
David Glick
 Web Developer
 davidgl...@groundwire.org
 206.286.1235x32

Groundwire: You Are Connected   
 http://groundwire.org  

Online tools and strategies for the environmental movement.  Sign up for 
Groundwire News!
 http://groundwire.org/email-capture


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-20 Thread Christian Zagrodnick
On 2011-02-19 17:17:44 +0100, Hanno Schlichting said:

 On Thu, Feb 17, 2011 at 8:27 AM, Christian Zagrodnick c...@gocept.com wrote:
 On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called

Sure. 
 
 I'll review, merge and release. Should be sometime this week,
 cannot promise a day.
 
 Branch reviewed, merged and released in Acquisition 2.13.6.
 
 Could you remove the merged branch once you updated your buildout config?

Done.

Thanks for releasing!


-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-19 Thread Hanno Schlichting
On Thu, Feb 17, 2011 at 8:27 AM, Christian Zagrodnick c...@gocept.com wrote:
 On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called

 Sure. I'll review, merge and release. Should be sometime this week,
 cannot promise a day.

Branch reviewed, merged and released in Acquisition 2.13.6.

Could you remove the merged branch once you updated your buildout config?

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-16 Thread Michael Howitz
Am 15.02.2011 um 14:35 schrieb Michael Howitz:
[...]
 print unicode(a.__of__(app))
 __str__ called
[...]
 This happens for Python 2.6 and 2.7 on Zope 2.13.4.

Zope 2.12.8 on Python 2.6 breaks the same way as 2.13.
But Zope 2.11.7 on Python 2.5 works correctly.

So either Python or Acquisition must have changed since than.

Any ideas?


Mit freundlichen Grüßen
-- 
Michael Howitz · m...@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

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-16 Thread Hanno Schlichting
On Wed, Feb 16, 2011 at 9:18 AM, Michael Howitz m...@gocept.com wrote:
 Zope 2.12.8 on Python 2.6 breaks the same way as 2.13.
 But Zope 2.11.7 on Python 2.5 works correctly.

 So either Python or Acquisition must have changed since than.

Acquisition changed a lot from 2.11 to 2.12 - it got support for
parent pointers for example. The full changelog is quite long, but
should be unrelated
(http://pypi.python.org/pypi/Acquisition#changelog).

The full diff is at:

svn di 
svn+ssh://svn.zope.org/repos/main/Acquisition/branches/2.11/src/Acquisition/_Acquisition.c
svn+ssh://svn.zope.org/repos/main/Acquisition/trunk/src/Acquisition/_Acquisition.c

There's nothing obvious I can see here.

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-16 Thread Christian Zagrodnick
On 2011-02-16 10:10:05 +0100, Hanno Schlichting said:

 On Wed, Feb 16, 2011 at 9:18 AM, Michael Howitz m...@gocept.com wrote:
 Zope 2.12.8 on Python 2.6 breaks the same way as 2.13.
 But Zope 2.11.7 on Python 2.5 works correctly.
 
 So either Python or Acquisition must have changed since than.
 
 Acquisition changed a lot from 2.11 to 2.12 - it got support for
 parent pointers for example. The full changelog is quite long, but
 should be unrelated
 (http://pypi.python.org/pypi/Acquisition#changelog).
 
 The full diff is at:
 
 svn di 
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/2.11/src/Acquisition/_Acquisition.c
svn+ssh://svn.zope.org/repos/main/Acquisition/trunk/src/Acquisition/_Acquisition.c

There's 
 
 nothing obvious I can see here.

I suspect a change in python (which I did not follow up after getting 
strange feelings when looking at PyObject_Unicode).

Nevertheless I've fixed that on a branch:

svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called

Hanno: 

Would you review that change please?

Thanks.
-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-16 Thread Hanno Schlichting
On Wed, Feb 16, 2011 at 10:19 PM, Christian Zagrodnick c...@gocept.com wrote:
 I suspect a change in python (which I did not follow up after getting
 strange feelings when looking at PyObject_Unicode).

 Nevertheless I've fixed that on a branch:

 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called

 Hanno:

 Would you review that change please?

Sure. I'll review, merge and release. Should be sometime this week,
cannot promise a day.

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-16 Thread Christian Zagrodnick
On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:

 On Wed, Feb 16, 2011 at 10:19 PM, Christian Zagrodnick c...@gocept.com 
 wrote:
 I suspect a change in python (which I did not follow up after getting
 strange feelings when looking at PyObject_Unicode).
 
 Nevertheless I've fixed that on a branch:
 
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called

Hanno:

Would 
 
 you review that change please?
 
 Sure. I'll review, merge and release. Should be sometime this week,
 cannot promise a day.

Thanks. There is no pressure. mr.developer FTW :)

Anyway, I've added another test to make myself more comfortable.

-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-15 Thread Michael Howitz
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 · m...@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

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-15 Thread Hanno Schlichting
On Tue, Feb 15, 2011 at 2:35 PM, Michael Howitz m...@gocept.com wrote:
 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.

Acquisition wrappers only fill the tp_repr and tp_str slot and as far
as I can tell there's no tp_unicode slot in PyObject_HEAD_INIT.

So I'm not sure how to add the C equivalent of a __unicode__ to the
Wrappertype and XaqWrappertype PyExtensionClasses. It would probably
have to do a lookup for a __unicode__ method on the wrapped instance,
call it if it exists and otherwise call its own __str__ - essentially
duplicating the logic of the string type.

My C-fu is too weak to attempt this. The workaround is to call
unicode(aq_base(my_object)).

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


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

2011-02-15 Thread Christian Zagrodnick
On 2011-02-15 15:26:28 +0100, Hanno Schlichting said:

 On Tue, Feb 15, 2011 at 2:35 PM, Michael Howitz m...@gocept.com wrote:
 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.
 
 Acquisition wrappers only fill the tp_repr and tp_str slot and as far
 as I can tell there's no tp_unicode slot in PyObject_HEAD_INIT.
 
 So I'm not sure how to add the C equivalent of a __unicode__ to the
 Wrappertype and XaqWrappertype PyExtensionClasses. It would probably
 have to do a lookup for a __unicode__ method on the wrapped instance,
 call it if it exists and otherwise call its own __str__ - essentially
 duplicating the logic of the string type.

Jup.

 
 My C-fu is too weak to attempt this.

Heh. My C-fu is also rather weak but I might try it if there are no 
objections.  (or there is somebody hacking it in 5 minutes …)

 The workaround is to call
 unicode(aq_base(my_object)).

Yes, but that's not really an option.

Regards,
-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )