[ZCM] [ZC] 1512/ 3 Comment "2.8 failure with Plone: DocumentTemplate.ustr.py"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Mon Oct 4 09:20:19 EDT 2004


Issue #1512 Update (Comment) "2.8 failure with Plone: DocumentTemplate.ustr.py"
 Status Pending, Zope/bug medium
To followup, visit:
  http://collector.zope.org/Zope/1512

==============================================================
= Comment - Entry #3 by yuppie on Oct 4, 2004 9:20 am

CMF 1.4.X is currently not Zope 2.8 compatibility.

Testing against Plone 2.0.X doesn't make much sense as long as the Zope 2.8 compatibility changes from CMF 1.5.X / HEAD are not backported to CMF 1.4.X.

This is the fix for the 'ustr' issue:
<http://cvs.zope.org/CMF/CMFCore/FSImage.py.diff?r1=1.15&r2=1.16>

________________________________________
= Comment - Entry #2 by ajung on Oct 4, 2004 8:55 am

The ustr() implementation look like this:

def ustr(v):
    """Convert any object to a plain string or unicode string,
    minimising the chance of raising a UnicodeError. This
    even works with uncooperative objects like Exceptions
    """
    string_types = (StringType,UnicodeType)
    if type(v) in string_types:
        return v
    else:
        fn = getattr(v,'__str__',None)
        if fn is not None:
            # An object that wants to present its own string representation,
            # but we dont know what type of string. We cant use any built-in
            # function like str() or unicode() to retrieve it because
            # they all constrain the type which potentially raises an exception.
            # To avoid exceptions we have to call __str__ direct.
            if getattr(fn,'im_func',None)==nasty_exception_str:
                # Exception objects have been optimised into C, and their
                # __str__ function fails when given a unicode object.
                # Unfortunately this scenario is all too common when
                # migrating to unicode, because of code which does:
                # raise ValueError(something_I_wasnt_expecting_to_be_unicode)
                return _exception_str(v)
            else:
                # Trust the object to do this right
                v = fn()

The object raising the problem is an ImplicitAqWrapper around
an FSImage instance. getattr(o, '__str__') seems to
return this unbound __str__ method. However I have no clue
where it is acquired from.




TypeError: 'unbound method __str__() must be called with Image instance as first argument (got nothing instead)'
> /develop/sandboxes/Zope/Zope/lib/python/DocumentTemplate/ustr.py(44)ustr()
-> v = fn()
(Pdb) print fn
<unbound method Image.__str__>
(Pdb) print v
*** TypeError: unbound method __str__() must be called with Image instance as first argument (got nothing instead)
(Pdb) print type(v)
<type 'ImplicitAcquirerWrapper'>
(Pdb) print type(v.aq_base)
<class 'Products.CMFCore.FSImage.FSImage'>
(Pdb) print v.__str__
<unbound method Image.__str__>
(Pdb) print v.aq_base.__str__
<unbound method Image.__str__>
(Pdb) v.aq_chain
[<Products.CMFCore.FSImage.FSImage object at 0x41646d0c>, <Products.CMFPlone.Portal.PloneSite object at 0x412006ac>, <OFS.Application.Application object at 0x411aebac>, <ZPublisher.BaseRequest.RequestContainer object at 0x4143394c>]

________________________________________
= Request - Entry #1 by ajung on Sep 29, 2004 11:24 am

Go to Plone setup -> Add/Remove products:

Time  	2004/09/29 17:21:24.653 GMT+2
User Name (User Id) 	admin (admin)
Request URL 	http://192.168.0.12:8080/222222222222/prefs_install_products_form
Exception Type 	TypeError
Exception Value 	unbound method __str__() must be called with Image instance as first argument (got nothing instead)

Traceback (innermost last):

    * Module ZPublisher.Publish, line 112, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 39, in call_object
    * Module Shared.DC.Scripts.Bindings, line 306, in __call__
    * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
    * Module Products.CMFCore.FSPageTemplate, line 191, in _exec
    * Module Products.CMFCore.FSPageTemplate, line 124, in pt_render
    * Module Products.PageTemplates.PageTemplate, line 102, in pt_render
      <FSPageTemplate at /222222222222/prefs_install_products_form>
    * Module TAL.TALInterpreter, line 190, in __call__
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 671, in do_useMacro
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 409, in do_optTag_tal
    * Module TAL.TALInterpreter, line 394, in do_optTag
    * Module TAL.TALInterpreter, line 389, in no_tag
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 671, in do_useMacro
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 409, in do_optTag_tal
    * Module TAL.TALInterpreter, line 394, in do_optTag
    * Module TAL.TALInterpreter, line 389, in no_tag
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 702, in do_defineSlot
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 409, in do_optTag_tal
    * Module TAL.TALInterpreter, line 394, in do_optTag
    * Module TAL.TALInterpreter, line 389, in no_tag
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 650, in do_defineMacro
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 694, in do_defineSlot
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 694, in do_defineSlot
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 613, in do_loop_tal
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 409, in do_optTag_tal
    * Module TAL.TALInterpreter, line 394, in do_optTag
    * Module TAL.TALInterpreter, line 389, in no_tag
    * Module TAL.TALInterpreter, line 234, in interpret
    * Module TAL.TALInterpreter, line 575, in do_insertStructure_tal
    * Module DocumentTemplate.ustr, line 43, in ustr

TypeError: unbound method __str__() must be called with Image instance as first argument (got nothing instead)
==============================================================



More information about the Zope-Collector-Monitor mailing list