Can't delete ZPT's

Bug #198274 reported by Peter Koppatz on 2008-03-04
2
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Medium
Tres Seaver

Bug Description

I created some ZPT's with Zope 2.9.x. These ZPT's have an empty string as content. The templates are added with:

manage_addProduct['PageTemplates'].manage_addPageTemplate(id=userid,text="")

Now with zope 2.11.x if I try to delete the ZPT an automatic unicode transformation starts.
This action fails, with the following message:

2008-03-04 07:13:00 INFO ZEO.ClientStorage (13387) Verifying cache
2008-03-04 07:13:00 INFO ZEO.ClientStorage (13387) endVerify finishing
2008-03-04 07:13:00 INFO ZEO.ClientStorage (13387) endVerify finished
2008-03-04 07:13:03 ERROR ZODB.Connection Couldn't load state for 0x06f649
Traceback (most recent call last):
  File "/opt/211b1/lib/python/ZODB/Connection.py", line 804, in setstate
    self._setstate(obj)
  File "/opt/211b1/lib/python/ZODB/Connection.py", line 863, in _setstate
    self._reader.setGhostState(obj, p)
  File "/opt/211b1/lib/python/ZODB/serialize.py", line 605, in setGhostState
    obj.__setstate__(state)
  File "/opt/211b1/lib/python/Products/PageTemplates/ZopePageTemplate.py", line 420, in __setstate__
    if not isinstance(state['_text'], unicode):
KeyError: '_text'

My workaround is add a test in /lib/python/Products/PageTemplates/ZopePageTemplate.py :

   def __setstate__(self, state):
        # Perform on-the-fly migration to unicode.
        # Perhaps it might be better to work with the 'generation' module
        # here?
        if state.has_key('_text'):
                if not isinstance(state['_text'], unicode):
                        text, encoding = convertToUnicode(state['_text'],
                                state.get('content_type', 'text/html'),
                                preferred_encodings)
                        state['_text'] = text
                        state['output_encoding'] = encoding
        self.__dict__.update(state)

With new created ZPT's there is no problem.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Koppatz wrote:
> Public bug reported:
>
> I created some ZPT's with Zope 2.9.x. These ZPT's have an empty string
> as content. The templates are added with:
>
> manage_addProduct['PageTemplates'].manage_addPageTemplate(id=userid,text="")
>
> Now with zope 2.11.x if I try to delete the ZPT an automatic unicode transformation starts.
> This action fails, with the following message:
>
> 2008-03-04 07:13:00 INFO ZEO.ClientStorage (13387) Verifying cache
> 2008-03-04 07:13:00 INFO ZEO.ClientStorage (13387) endVerify finishing
> 2008-03-04 07:13:00 INFO ZEO.ClientStorage (13387) endVerify finished
> 2008-03-04 07:13:03 ERROR ZODB.Connection Couldn't load state for 0x06f649
> Traceback (most recent call last):
> File "/opt/211b1/lib/python/ZODB/Connection.py", line 804, in setstate
> self._setstate(obj)
> File "/opt/211b1/lib/python/ZODB/Connection.py", line 863, in _setstate
> self._reader.setGhostState(obj, p)
> File "/opt/211b1/lib/python/ZODB/serialize.py", line 605, in setGhostState
> obj.__setstate__(state)
> File "/opt/211b1/lib/python/Products/PageTemplates/ZopePageTemplate.py", line 420, in __setstate__
> if not isinstance(state['_text'], unicode):
> KeyError: '_text'
>
> My workaround is add a test in
> /lib/python/Products/PageTemplates/ZopePageTemplate.py :
>
> def __setstate__(self, state):
> # Perform on-the-fly migration to unicode.
> # Perhaps it might be better to work with the 'generation' module
> # here?
> if state.has_key('_text'):
> if not isinstance(state['_text'], unicode):
> text, encoding = convertToUnicode(state['_text'],
> state.get('content_type', 'text/html'),
> preferred_encodings)
> state['_text'] = text
> state['output_encoding'] = encoding
> self.__dict__.update(state)
>
> With new created ZPT's there is no problem.
>
> ** Affects: zope2
> Importance: Undecided
> Status: New
>

I can confirm the bug, with a unit test (see attached patch).

Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 <email address hidden>
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHzY1Z+gerLs4ltQ4RAukHAJ9HN44SVZUxm/ozXHDDgti3H24AugCbBKK5
AUSpovVQH/fE81Ex2hP9grc=
=yiFm
-----END PGP SIGNATURE-----

Tres Seaver (tseaver) wrote :

This bug affects Zope 2.10 as well as 2.11 and the trunk. I have committed
the test and fix to all three branches:

 - http://svn.zope.org/Zope/branches/2.10/?rev=84462&view=rev

 - http://svn.zope.org/Zope/branches/2.11/?rev=84463&view=rev

 - http://svn.zope.org/Zope/trunk/?rev=84464&view=rev

Changed in zope2:
assignee: nobody → tseaver
importance: Undecided → Medium
status: New → Fix Committed
Tres Seaver (tseaver) wrote :

Included in 2.10.6 and 2.11.0.

Changed in zope2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers