Comment 1 for bug 410238

Revision history for this message
Maurits van Rees (maurits-vanrees) wrote :

This happens when you have added a style sheet (well, some css lines) in the composer. It can be tested simply by rendering the preview of the news letter. Using cssutils=0.9.6b1 indeed fixes it for me too. But that gives problems with some css lines; for example with this css it fails too:

   * {
    margin: 0;
    padding: 0;
   }

Those lines are given to me by the local css guru, so I assume they are fine. :-)

Traceback is then this, apparently because '*' is not recognized by StoneageHTML as a selector:

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module Products.PDBDebugMode.pdbzope.runcall, line 60, in pdb_runcall
  Module ZPublisher.Publish, line 42, in call_object
  Module collective.dancing.browser.preview, line 67, in __call__
  Module collective.singing.scheduler, line 109, in render_message
  Module collective.dancing.composer, line 230, in render
  Module plone.memoize.volatile, line 272, in replacement
  Module collective.dancing.composer, line 220, in _render
  Module stoneagehtml.stoneagehtml, line 91, in compactify
  Module stoneagehtml.stoneagehtml, line 228, in compactify
  Module stoneagehtml.stoneagehtml, line 271, in distributeCSSDeclaration
  Module stoneagehtml.stoneagehtml, line 292, in distributeCSSRule
IndexError: list index out of range

Might it be a good idea to use stoneagehtml only when it works and just use the original html otherwise? So something like this:

html = method_to_render_original_html()
try:
    html = stoneagehtml.compactify(html).decode('utf-8')
except:
    logger.warn('Exception while compacting html with stoneagehtml; using original instead.')