[Erp5-report] r13255 - in /erp5/trunk/products/ERP5/Document: Document.py PDFDocument.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Mar 7 12:42:18 CET 2007
Author: bartek
Date: Wed Mar 7 12:42:14 2007
New Revision: 13255
URL: http://svn.erp5.org?rev=13255&view=rev
Log:
convertToBase moved to Document as generic method; fixed calls to processing status workflow;
Modified:
erp5/trunk/products/ERP5/Document/Document.py
erp5/trunk/products/ERP5/Document/PDFDocument.py
Modified: erp5/trunk/products/ERP5/Document/Document.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Document.py?rev=13255&r1=13254&r2=13255&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Document.py (original)
+++ erp5/trunk/products/ERP5/Document/Document.py Wed Mar 7 12:42:14 2007
@@ -320,6 +320,7 @@
'subject', 'source_reference', 'source_project_title')
data = '' # some day this will be in property sheets
+ base_format = 'base storage format'
### Content processing methods
security.declareProtected(Permissions.View, 'index_html')
@@ -900,13 +901,44 @@
return self._getTypeBasedMethod('finishIngestion',
fallback_script_id='Document_finishIngestion')
- def convertToBase(self):
+ security.declareProtected(Permissions.View, 'convert')
+ def convertToBase(self, REQUEST=None):
+ """
+ This is run upon upload of the file to make the first
+ conversion; calls _convertToBase which be default does
+ nothing.
+ Records the result in processing_status_workflow
+ In OOo documents it converts into ODF format so that we can easily
+ convert into other formats, play with metadata and such.
+ In PDF doc it converts to plain text, so that we don't have to
+ reconvert every time we reindex the object.
+ """
+ try:
+ msg = self._convertToBase()
+ if msg is None:
+ msg = 'Converted to %s.' % self.base_format
+ self.convertFile(comment=msg) # Invoke workflow method
+ except NotImplementedError:# we don't do any workflow action if nothing has been done
+ msg = ''
+ except ConversionError, e:
+ msg = 'Problem: %s' % (str(e) or 'undefined.')
+ self.processFile(comment=msg)
+ except Fault, e:
+ msg = 'Problem: %s' % (repr(e) or 'undefined.')
+ self.processFile(comment=msg)
+ except socket.error, e:
+ msg = 'Problem: %s' % (repr(e) or 'undefined.')
+ self.processFile(comment=msg)
+ return msg
+
+
+ def _convertToBase(self):
"""
API method - some subclasses store data in a certain 'base' format
(e.g. OOoDocument uses ODF)
XXX-JPS What is this ? Explain. Name unclear
"""
- pass
+ raise NotImplementedError
# vim: filetype=python syntax=python shiftwidth=2
Modified: erp5/trunk/products/ERP5/Document/PDFDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PDFDocument.py?rev=13255&r1=13254&r2=13255&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFDocument.py (original)
+++ erp5/trunk/products/ERP5/Document/PDFDocument.py Wed Mar 7 12:42:14 2007
@@ -139,7 +139,6 @@
We mark it in cache as done, even if we fail, so we don't keep trying if it
doesn't work.
"""
- portal_workflow = getToolByName(self, 'portal_workflow')
if hasattr(self, 'data') and (force == 1 or not self.hasConversion(format = 'txt')):
# XXX-JPS accessing attribute data is bad
self.log('PdfDocument', 'regenerating txt')
@@ -159,12 +158,16 @@
else:
msg = 'Converted to text'
finally:
- portal_workflow.doActionFor(self, 'process', comment=msg)
+ self.processFile(comment=msg)
# we don't need to store it twice, just mark we have it (or rather we already tried)
# we try only once
self.setConversion('empty', format = 'txt')
SearchableText=getSearchableText
+
+ security.declarePrivate('_convertToBase')
+ def _convertToBase(self):
+ self._convertToText(force=1)
security.declareProtected(Permissions.View, 'getHtmlRepresentation')
def getHtmlRepresentation(self, force=0):
More information about the Erp5-report
mailing list