From be54ab8d5764b1bd229b3c52c7b2806f4a8c65d7 Mon Sep 17 00:00:00 2001
From: Yusei Tahara <yusei@nexedi.com>
Date: Wed, 12 Dec 2007 15:50:20 +0000
Subject: [PATCH] Output more information.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18269 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_dms/Document_getPreviewAsHTML.xml    | 27 +++++++++++++++----
 bt5/erp5_dms/bt/revision                      |  2 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Document_getPreviewAsHTML.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Document_getPreviewAsHTML.xml
index ab4e5083f4..cdb408e311 100644
--- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Document_getPreviewAsHTML.xml
+++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Document_getPreviewAsHTML.xml
@@ -67,13 +67,26 @@
             <key> <string>_body</string> </key>
             <value> <string encoding="cdata"><![CDATA[
 
+from Products.PythonScripts.standard import html_quote\n
+\n
+result = \'\'\n
+error_message = None\n
 try:\n
-  return context.asStrippedHTML()\n
+  result = context.asStrippedHTML()\n
+  if result:\n
+    return result\n
+  if not context.hasBaseData():\n
+    error_message = context.Base_translateString("This document is not converted yet.")\n
 except Exception, e:\n
   from Products.ERP5Type.Log import log\n
   log("asStrippedHTML", str(e))\n
-  error_message = context.Base_translateString("Preview Error.")\n
-  return \'<div class="error">%s</div>\' % error_message\n
+  error_message = "%s %s" % (context.Base_translateString("Preview Error:"),\n
+                              str(e))\n
+\n
+if error_message is not None:\n
+  return \'<div class="error">%s</div>\' % html_quote(error_message)\n
+\n
+return result\n
 
 
 ]]></string> </value>
@@ -118,14 +131,18 @@ except Exception, e:\n
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
+                            <string>Products.PythonScripts.standard</string>
+                            <string>html_quote</string>
+                            <string>result</string>
+                            <string>None</string>
+                            <string>error_message</string>
                             <string>_getattr_</string>
-<string>context</string>
+                            <string>context</string>
                             <string>Exception</string>
                             <string>e</string>
                             <string>Products.ERP5Type.Log</string>
                             <string>log</string>
                             <string>str</string>
-                            <string>error_message</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_dms/bt/revision b/bt5/erp5_dms/bt/revision
index 475fbacb43..5d5ad96f9f 100644
--- a/bt5/erp5_dms/bt/revision
+++ b/bt5/erp5_dms/bt/revision
@@ -1 +1 @@
-763
\ No newline at end of file
+764
\ No newline at end of file
-- 
2.30.9