Commit 75f9aa2e authored by Jean-Paul Smets's avatar Jean-Paul Smets

Fixed some syntax. Renamed abbreviated variables with verbose names. Made sure...

Fixed some syntax. Renamed abbreviated variables with verbose names. Made sure that if conversion fails, then an error is raised (rather than return empty strings).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17512 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21d292e8
...@@ -547,12 +547,12 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -547,12 +547,12 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
later stage of the implementation. later stage of the implementation.
""" """
# XXX results should be cached as volatile attributes # XXX results should be cached as volatile attributes
refs = [r[1] for r in self.getSearchableReferenceList()] reference_list = [r[1] for r in self.getSearchableReferenceList()]
res = self.Base_getImplicitSuccessorValueList(refs) result = self.Base_getImplicitSuccessorValueList(reference_list)
# get unique latest (most relevant) versions # get unique latest (most relevant) versions
res = [r.getObject().getLatestVersionValue() for r in res] result = [r.getObject().getLatestVersionValue() for r in result]
res_dict = dict.fromkeys(res) result_dict = dict.fromkeys(result)
return res_dict.keys() return result_dict.keys()
security.declareProtected(Permissions.AccessContentsInformation, 'getImplicitPredecessorValueList') security.declareProtected(Permissions.AccessContentsInformation, 'getImplicitPredecessorValueList')
def getImplicitPredecessorValueList(self): def getImplicitPredecessorValueList(self):
...@@ -870,7 +870,6 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -870,7 +870,6 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
res = catalog(reference=self.getReference(), sort_on=(('creation_date','ascending'),)) res = catalog(reference=self.getReference(), sort_on=(('creation_date','ascending'),))
# XXX this should be security-unaware - delegate to script with proxy roles # XXX this should be security-unaware - delegate to script with proxy roles
return res[0].getLanguage() # XXX what happens if it is empty? return res[0].getLanguage() # XXX what happens if it is empty?
### Property getters ### Property getters
# Property Getters are document dependent so that we can # Property Getters are document dependent so that we can
...@@ -991,13 +990,13 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -991,13 +990,13 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
# Try not to invoke an automatic transition here # Try not to invoke an automatic transition here
self._edit(**kw) self._edit(**kw)
# Finish ingestion by calling method # Finish ingestion by calling method
self.finishIngestion() self.finishIngestion()
self.reindexObject() self.reindexObject()
# Revision merge is tightly coupled # Revision merge is tightly coupled
# to metadata discovery - refer to the documentation of mergeRevision method # to metadata discovery - refer to the documentation of mergeRevision method
merged_doc = self.mergeRevision() merged_doc = self.mergeRevision()
merged_doc.reindexObject() merged_doc.reindexObject()
return merged_doc return merged_doc
security.declareProtected(Permissions.ModifyPortalContent, 'finishIngestion') security.declareProtected(Permissions.ModifyPortalContent, 'finishIngestion')
def finishIngestion(self): def finishIngestion(self):
...@@ -1070,7 +1069,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -1070,7 +1069,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
is the one to override in subclasses. is the one to override in subclasses.
""" """
if not self.hasBaseData(): if not self.hasBaseData():
return '' raise ConversionError('This document has not been processed yet.')
if self.hasConversion(format='base-html'): if self.hasConversion(format='base-html'):
mime, data = self.getConversion(format='base-html') mime, data = self.getConversion(format='base-html')
return data return data
...@@ -1098,7 +1097,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -1098,7 +1097,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
# find charset and convert to utf-8 # find charset and convert to utf-8
charset_list = self.charset_parser.findall(str(html)) # XXX - Not efficient is datastream charset_list = self.charset_parser.findall(str(html)) # XXX - Not efficient is datastream
# instance but hard to do better # instance but hard to do better
if charset_list: if charset_list and charset_list[0] not in ('utf-8', 'UTF-8'):
stripped_html = unicode(str(stripped_html), charset_list[0]).encode('utf-8') stripped_html = unicode(str(stripped_html), charset_list[0]).encode('utf-8')
return stripped_html return stripped_html
......
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