[ZCM] [ZC] 1219/ 8 Comment "XML export broken"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Fri Oct 15 11:22:55 EDT 2004


Issue #1219 Update (Comment) "XML export broken"
 Status Pending, Zope/bug medium
To followup, visit:
  http://collector.zope.org/Zope/1219

==============================================================
= Comment - Entry #8 by dpollard on Oct 15, 2004 11:22 am

XML export appears to have 3 problems. Several edits to 
/usr/local/zope-2.7.2/lib/python/Shared/DC/xml/ppml.py has got XML export working for me. Others may like to try them out.

1. The "extend" problem, solved by adding 
def extend(self, v): self._subs.extend(v) to 
class Sequence(Collection)
as documented previously.

2. The "'unicode' object has no attribute 'id'" problem
This can be fixed by adding a couple of 'if' statements.

In the function load_binput at line 409, check for the existence of the id attribute by adding the 'if' test
before the 'id' attribute gets changed.
   if hasattr(self.stack[-1], 'id'):
      self.stack[-1].id=self.idprefix+`i`

Do the same again in the function load_long_binput at line 415.

3. The "TypeError: function takes exactly 0 arguments (1 given)"
This can be fixed by removing the argument to v.__str__
at line 172 in def __str__, in class Wrapper 
and
at line 223 in def value, in class Sequence(Collection)

________________________________________
= Comment - Entry #7 by PatrickD on Oct 7, 2004 12:50 pm

Like patros said in followup #5, the following patch solves the bug:

$ diff -c Zope-2.7.2-0-orig/lib/python/Shared/DC/xml/ppml.py Zope-2.7.2-0/lib/p
ython/Shared/DC/xml/ppml.py
*** Zope-2.7.2-0-orig/lib/python/Shared/DC/xml/ppml.py  Wed Aug 14 23:51:00 2002

--- Zope-2.7.2-0/lib/python/Shared/DC/xml/ppml.py       Thu Oct  7 18:36:17 2004

***************
*** 221,226 ****
--- 221,228 ----
              lambda v, indent=indent: v.__str__(indent),
              self._subs),'')

+     def extend(self, v): self._subs.extend(v)
+
  class List(Sequence): pass
  class Tuple(Sequence): pass

________________________________________
= Comment - Entry #6 by ajung on May 28, 2004 10:21 am

I can no longer the 'extend' problem. XML export with 2.7.1b1
works fine. However I can still reproduce my problem as transcript in followup #2. No idea how to fix it.

Because the binary export/import is working this is not
so important.
________________________________________
= Comment - Entry #5 by patros on May 24, 2004 10:14 am

added line in class Sequence(Collection) solves the bug:
    def extend(self, v): self._subs.extend(v)


________________________________________
= Comment - Entry #4 by ajung on May 18, 2004 3:46 am

See also #1340
________________________________________
= Comment - Entry #3 by bkulawik on Mar 9, 2004 9:27 am

I have the same problem, and I tried the solution suggested by Clemens Robbenhaar - but unfortunately it didn't work [ even when I corrected the obvious typo at the end where self._subs.extens(v) should be - IMHO - self._subs.extend(v) ] Could anyone give a helpful solution, please?

<snip>
"The class "List" which does not has the attribute "extend"
is defined in the "ppml.py" (in lib/python/Shared/DC/xml)

Maybe You could try to add such a method to its base class "Sequence",
defined in the same file; e.g. to the class definition:

class Sequence(Collection):

    def __init__(self, v=None):
        if not v: v=[]
        self._subs=v

    def __len__(self): return len(self._subs)

    def append(self, v): self._subs.append(v)

    def value(self, indent):
        return string.join(map(
            lambda v, indent=indent: v.__str__(indent),
            self._subs),'')

append something like:

    def extend(self, v): self._subs.extens(v)
</snip>



________________________________________
= Comment - Entry #2 by ajung on Feb 11, 2004 2:39 am

I confirm this bug and figured out a new one:

Time  	2004/02/11 08:36:31.223 GMT+1
User Name (User Id) 	ajung (ajung)
Request URL 	http://xweb3:29080/plone_trackers/manage_exportObject
Exception Type 	AttributeError
Exception Value 	'unicode' object has no attribute 'id'

Traceback (innermost last):

    * Module ZPublisher.Publish, line 112, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 47, in call_object
    * Module OFS.ObjectManager, line 513, in manage_exportObject
    * Module OFS.XMLExportImport, line 58, in exportXML
    * Module OFS.XMLExportImport, line 33, in XMLrecord
    * Module Shared.DC.xml.ppml, line 253, in load
    * Module pickle, line 872, in load
    * Module Shared.DC.xml.ppml, line 406, in load_binput

AttributeError: 'unicode' object has no attribute 'id'


Also Zope 2.7/HEAD + Python 2.3.3.
________________________________________
= Request - Entry #1 by jxr on Feb 6, 2004 1:20 pm

XML export is apparently broken for some objects.
Here an example on exporting a ZSQL method:

Traceback (innermost last):
  Module ZPublisher.Publish, line 100, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 40, in call_object
  Module OFS.ObjectManager, line 502, in manage_exportObject
  Module OFS.XMLExportImport, line 58, in exportXML
  Module OFS.XMLExportImport, line 33, in XMLrecord
  Module Shared.DC.xml.ppml, line 253, in load
  Module pickle, line 872, in load
  Module pickle, line 1209, in load_appends
AttributeError: List instance has no attribute 'extend'
==============================================================



More information about the Zope-Collector-Monitor mailing list