From 2e72210418a3ba400daaab7e58e021db43aef0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl> Date: Wed, 27 Sep 2006 11:29:34 +0000 Subject: [PATCH] cleared redundant date information; fixed some bugs; git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10353 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5OOo/Document/DMSFile.py | 10 +++++++ product/ERP5OOo/Document/OOoDocument.py | 31 ++++---------------- product/ERP5OOo/PropertySheet/OOoDocument.py | 24 --------------- 3 files changed, 15 insertions(+), 50 deletions(-) diff --git a/product/ERP5OOo/Document/DMSFile.py b/product/ERP5OOo/Document/DMSFile.py index 4d62d7d335..5e1249c9c6 100644 --- a/product/ERP5OOo/Document/DMSFile.py +++ b/product/ERP5OOo/Document/DMSFile.py @@ -171,6 +171,16 @@ class DMSFile(XMLObject,File): searchable_text = ' '.join(map(lambda x: self.getProperty(x) or ' ',self.searchable_attrs)) return searchable_text + security.declareProtected(Permissions.View,'hasFile') + def hasFile(self): + """ + Checks whether we have an initial file + """ + _marker=[] + if getattr(self,'data',_marker) is not _marker: # XXX - use propertysheet accessors + return getattr(self,'data') is not None + return False + security.declarePrivate('_unpackData') def _unpackData(self,data): """ diff --git a/product/ERP5OOo/Document/OOoDocument.py b/product/ERP5OOo/Document/OOoDocument.py index 8a25f04273..59c9c90a19 100644 --- a/product/ERP5OOo/Document/OOoDocument.py +++ b/product/ERP5OOo/Document/OOoDocument.py @@ -144,13 +144,13 @@ class OOoDocument(DMSFile, CachingMixin): communicates with the conversion server and gets converted file as well as metadata """ - if force==0 and not self.isFileUploaded(): + if force==0 and self.hasOOfile(): return self.returnMessage('OOo file is up do date',1) try: self._convert() except xmlrpclib.Fault,e: return self.returnMessage('Problem: %s' % str(e),2) - self.setLastConvertTime(DateTime()) + #self.setLastConvertTime(DateTime()) return self.returnMessage('converted') security.declareProtected(Permissions.AccessContentsInformation,'getTargetFormatList') @@ -279,16 +279,6 @@ class OOoDocument(DMSFile, CachingMixin): data=self.oo_data return data - security.declareProtected(Permissions.View,'hasFile') - def hasFile(self): - """ - Checks whether we have an initial file - """ - _marker=[] - if getattr(self,'data',_marker) is not _marker: # XXX - use propertysheet accessors - return getattr(self,'data') is not None - return False - security.declareProtected(Permissions.View,'hasOOfile') def hasOOfile(self): """ @@ -331,8 +321,7 @@ class OOoDocument(DMSFile, CachingMixin): return self.returnMessage('no pdf format found') fmt=tgts[0] self.makeFile(fmt) - #self.snapshot=Pdata(self._unpackData(self.cached_data[fmt])) - self.snapshot=Pdata(self._unpackData(self.cacheGet(format)[1])) + self.snapshot=Pdata(self._unpackData(self.cacheGet(fmt)[1])) return self.returnMessage('snapshot created') security.declareProtected(Permissions.View,'getSnapshot') @@ -391,23 +380,13 @@ class OOoDocument(DMSFile, CachingMixin): except ConvertionError,e: return self.returnMessage(str(e)) - security.declareProtected(Permissions.View,'isFileUploaded') - def isFileUploaded(self): - """ - Checks whether the file was uploaded after the last conversion into OOo - """ - if not self.hasOOfile():return True - return self.getLastUploadTime() > self.getLastConvertTime() - security.declareProtected(Permissions.View,'isFileChanged') def isFileChanged(self,format): """ Checks whether the file was converted (or uploaded) after last generation of the target format """ - if self.isFileUploaded(): return True - if not self.hasFileCache(format):return True - return self.getLastConvertTime()>self.getCacheTime(format) + return not self.hasFileCache(format) security.declareProtected(Permissions.ModifyPortalContent,'makeFile') def makeFile(self,format,REQUEST=None): @@ -426,7 +405,7 @@ class OOoDocument(DMSFile, CachingMixin): if REQUEST is not None: return self.returnMessage(errstr) raise ConvertionError(errstr) - if self.isFileUploaded(): + if not self.hasOOfile(): if REQUEST is not None: return self.returnMessage('needs conversion') raise ConvertionError('needs conversion') diff --git a/product/ERP5OOo/PropertySheet/OOoDocument.py b/product/ERP5OOo/PropertySheet/OOoDocument.py index e6bc594cc2..156e546a61 100644 --- a/product/ERP5OOo/PropertySheet/OOoDocument.py +++ b/product/ERP5OOo/PropertySheet/OOoDocument.py @@ -31,30 +31,6 @@ class OOoDocument: """ _properties = ( - { 'id' : 'original_format', - 'description' : 'format of the uploaded file', - 'type' : 'string', - 'mode' : '' }, - { 'id' : 'pdf_generation_time', - 'description' : 'when pdf was generated', - 'type' : 'date', - 'mode' : ''}, - { 'id' : 'last_upload_time', - 'description' : 'when the file was last uploaded', - 'type' : 'date', - 'mode' : ''}, - { 'id' : 'last_convert_time', - 'description' : 'when the file was last converted', - 'type' : 'date', - 'mode' : ''}, - { 'id' : 'keywords', - 'description' : 'keywords', - 'type' : 'string', - 'mode' : ''}, - { 'id' : 'allowed_targets', - 'description':'a list of formats we can generate from OOo doc we have', - 'type' : 'lines', - 'mode' : ''}, { 'id' : 'mime_type', 'description' : 'mime type of OOo version', 'type' : 'string', -- 2.30.9