[Erp5-report] r21993 - /erp5/trunk/products/ERP5/Document/TextDocument.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 27 02:05:18 CEST 2008


Author: yo
Date: Fri Jun 27 02:05:17 2008
New Revision: 21993

URL: http://svn.erp5.org?rev=21993&view=rev
Log:
If a substitution mapping method is not found, skip substitutions rather than raising an exception. This may happen when a web page is viewed directly, for example.

Modified:
    erp5/trunk/products/ERP5/Document/TextDocument.py

Modified: erp5/trunk/products/ERP5/Document/TextDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TextDocument.py?rev=21993&r1=21992&r2=21993&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TextDocument.py (original)
+++ erp5/trunk/products/ERP5/Document/TextDocument.py Fri Jun 27 02:05:17 2008
@@ -157,7 +157,11 @@
       # avoid encoding errors.
       method_id = self.getTextContentSubstitutionMappingMethodId()
       if method_id:
-        mapping = guarded_getattr(self, method_id)(**kw)
+        try:
+          mapping = guarded_getattr(self, method_id)(**kw)
+        except AttributeError:
+          LOG('TextDocument', WARNING, 'could not get the substitution mapping method %s from %r, so the content will not be substituted.' % (method_id, self))
+          mapping = {}
 
         is_str = isinstance(text, str)
         if is_str:




More information about the Erp5-report mailing list