Commit 785037e6 authored by Jérome Perrin's avatar Jérome Perrin

support empty documents:

 - getPropretyDictFromContent does not try to find anything from empty content
 - convertTotBaseFormat does not try to convert



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31569 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5966ebe
...@@ -986,6 +986,9 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S ...@@ -986,6 +986,9 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S
Based on the document content, find out as many properties as needed. Based on the document content, find out as many properties as needed.
returns properties which should be set on the document returns properties which should be set on the document
""" """
if not self.hasData():
# if document is empty, we will not find anything in its content
return dict()
if not self.hasBaseData(): if not self.hasBaseData():
raise NotConvertedError raise NotConvertedError
method = self._getTypeBasedMethod('getPropertyDictFromContent', method = self._getTypeBasedMethod('getPropertyDictFromContent',
...@@ -1274,6 +1277,9 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S ...@@ -1274,6 +1277,9 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S
using the base_data property. Refer to Document.py propertysheet. using the base_data property. Refer to Document.py propertysheet.
Use accessors (getBaseData, setBaseData, hasBaseData, etc.) Use accessors (getBaseData, setBaseData, hasBaseData, etc.)
""" """
if not self.hasData():
# Empty document cannot be converted
return #'Document is empty'
try: try:
message = self._convertToBaseFormat() # Call implemetation method message = self._convertToBaseFormat() # Call implemetation method
self.clearConversionCache() # Conversion cache is now invalid self.clearConversionCache() # Conversion cache is now invalid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment