Beginners issue with nested dos

Asked by David Björkevik

Hi! I'm trying out appy.pod as a report generator. I try to set up a really minimal example with a ods template using conditional columns, which causes an exception in appy. Have I just got things very wrong or does this simple use case trigger a bug?

Code is below. appytest.ods is at http://www.bjorkevik.se/david/appytest.ods

#####################

from appy.pod.renderer import Renderer

staff = [{'firstName': 'Delannay', 'name': 'Gaetan', 'age': 112},
         {'firstName': 'Gauthier', 'name': 'Bastien', 'age': 5},
         {'firstName': 'Jean-Michel', 'name': 'Abe', 'age': 79}]

renderer = Renderer('appytest.ods', {
                                     "staff":staff,
                                     "print_age": False
                                     }, 'result.ods',
                    overwriteExisting=True)
renderer.run()

Question information

Language:
English Edit question
Status:
Answered
For:
Appy Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
David Björkevik (o-david-r) said :
#1

Forgot to add the traceback I get from running this:
Traceback (most recent call last):
  File "play_with_appy.py", line 12, in <module>
    renderer.run()
  File "/home/david/tmp/appytest/appy/pod/renderer.py", line 430, in run
    self.currentParser.parse(self.contentXml)
  File "/home/david/tmp/appytest/appy/shared/xml_parser.py", line 262, in parse
    self.parser.parse(inputSource)
  File "/usr/lib64/python2.7/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib64/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/usr/lib64/python2.7/xml/sax/expatreader.py", line 210, in feed
    self._parser.Parse(data, isFinal)
  File "/usr/lib64/python2.7/xml/sax/expatreader.py", line 307, in end_element
    self._cont_handler.endElement(name)
  File "/home/david/tmp/appytest/appy/pod/pod_parser.py", line 317, in endElement
    isMainElement = e.currentBuffer.isMainElement(elem)
  File "/home/david/tmp/appytest/appy/pod/buffers.py", line 287, in isMainElement
    if hasattr(mainElem, 'OD'): mainElem = mainElem.OD.elem
AttributeError: 'NoneType' object has no attribute 'elem'

The template file is made using LibreOffice 4.1.6.2. For the above test i use the bzr trunk head, but it crashes in a similar way with latest stable release.

Revision history for this message
Gaëtan Delannay (gaetan-delannay) said :
#2

Hi David,
The conditional inclusion of columns is a tricky thing and does not work yet. If you remove your 2 "do cell" statements, it should work.
Cheers,
Gaetan

Can you help with this problem?

Provide an answer of your own, or ask David Björkevik for more information if necessary.

To post a message you must log in.