Dethe Elza wrote:
I'm trying to build a lightweight templating system around docutils. ... If there are errors, I want the option of allowing the error to be processed normally (resulting in an HTML fragment with embedded error messages) or throw an exception (so I can trap it and display the text instead).
Use the "--traceback" option ("traceback" setting) to allow exceptions to propagate to the calling code. The program logic for exception handling is in docutils.core.Publisher.publish(). Use "--report" and/or "--halt" options ("report_level" & "halt_level" settings) for fine control. See <http://docutils.sf.net/docs/config.html>, "[general]" section, for details.
I've found that if the docutils processor is running on a file, I cannot get it to throw an exception all the way out to the calling method (it traps and processes it internally), while if I use a StringIO it causes exceptions that don't show up in the file processing.
I suspect this may be a red herring. What Python version? There's a StringIO bug in Python 2.1 or 2.2.
Docutils appears to be using the file object as it's state machine and calling methods which aren't part of the StringIO. Finally, if I use a StringIO, I have trouble with the include directive.
I don't follow. Please provide some supporting evidence. -- David Goodger http://starship.python.net/~goodger For hire: http://starship.python.net/~goodger/cv Docutils: http://docutils.sourceforge.net/ (includes reStructuredText: http://docutils.sf.net/rst.html)