comparison MoinMoin/items/content.py @ 1897:df3e72208eed

catch exceptions happening in the converters, show time/url for crash and hint to look into the log file
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 23 Dec 2012 23:23:19 +0100
parents a1edfcdddd34
children 2b4bcb80d644
comparison
equal deleted inserted replaced
1896:42b5d70289f9 1897:df3e72208eed
230 doc = link_conv(doc) 230 doc = link_conv(doc)
231 flaskg.clock.stop('conv_link') 231 flaskg.clock.stop('conv_link')
232 return doc 232 return doc
233 233
234 def _render_data(self): 234 def _render_data(self):
235 from MoinMoin.converter import default_registry as reg 235 try:
236 # TODO: Real output format 236 from MoinMoin.converter import default_registry as reg
237 doc = self.internal_representation() 237 # TODO: Real output format
238 doc = self._expand_document(doc) 238 doc = self.internal_representation()
239 flaskg.clock.start('conv_dom_html') 239 doc = self._expand_document(doc)
240 html_conv = reg.get(type_moin_document, Type('application/x-xhtml-moin-page')) 240 flaskg.clock.start('conv_dom_html')
241 doc = html_conv(doc) 241 html_conv = reg.get(type_moin_document, Type('application/x-xhtml-moin-page'))
242 flaskg.clock.stop('conv_dom_html') 242 doc = html_conv(doc)
243 rendered_data = conv_serialize(doc, {html.namespace: ''}) 243 flaskg.clock.stop('conv_dom_html')
244 rendered_data = conv_serialize(doc, {html.namespace: ''})
245 except Exception:
246 # we really want to make sure that invalid data or a malfunctioning
247 # converter does not crash the item view (otherwise a user might
248 # not be able to fix it from the UI).
249 logging.exception("An exception happened in _render_data:")
250 import time
251 rendered_data = render_template('crash.html',
252 server_time=time.strftime("%Y-%m-%d %H:%M:%S %Z"),
253 url=request.url)
244 return rendered_data 254 return rendered_data
245 255
246 def _render_data_xml(self): 256 def _render_data_xml(self):
247 doc = self.internal_representation() 257 doc = self.internal_representation()
248 return conv_serialize(doc, 258 return conv_serialize(doc,