[Erp5-report] r23234 - /erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Aug 28 16:06:28 CEST 2008
Author: nicolas
Date: Thu Aug 28 16:06:00 2008
New Revision: 23234
URL: http://svn.erp5.org?rev=23234&view=rev
Log:
handle KeyError Exception when it try to get a Document from ZODB
Handle case when css_object is not a DTMLDocument
Modified:
erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py
Modified: erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py?rev=23234&r1=23233&r2=23234&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py (original)
+++ erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py Thu Aug 28 16:06:00 2008
@@ -2,6 +2,7 @@
from Products.PortalTransforms.interfaces import idatastream
from Products.ERP5Type.Document import newTempOOoDocument
from Products.CMFCore.utils import getToolByName
+from Acquisition import aq_base
try:
from Products.ERP5OOo.OOoUtils import OOoBuilder
import re
@@ -86,7 +87,7 @@
path = matching.groupdict().get('path')
try:
image = self.context.restrictedTraverse(path)
- except AttributeError:
+ except (AttributeError, KeyError):
#Image not found, this image is probably not hosted by ZODB. Do nothing
image = None
if image is not None:
@@ -102,7 +103,7 @@
data = image.getData()
height = image.getHeight()
width = image.getWidth()
- except AttributeError:
+ except (AttributeError, KeyError):
#OFS API
data = image.data
height = image.height
@@ -137,12 +138,17 @@
if matching is not None:
path = matching.groupdict().get('path')
try:
- css = self.context.restrictedTraverse(path)
- except AttributeError:
+ css_object = self.context.restrictedTraverse(path)
+ except (AttributeError, KeyError):
#Image not found, this image is probably not hosted by ZODB. Do nothing
- css = None
- if css is not None:
- css_as_text = css(client=self.context.getPortalObject())
+ css_object = None
+ if css_object is not None:
+ if callable(aq_base(css_object)):
+ #In case of DTMLDocument
+ css_as_text = css_object(client=self.context.getPortalObject())
+ else:
+ #Other cases like files
+ css_as_text = str(css_object)
style_node = xml_doc.newChild(None, 'style', css_as_text)
style_node.setProp('type', 'text/css')
css_link_tag.replaceNode(style_node)
More information about the Erp5-report
mailing list