Commit c9db3aee authored by Mame Coumba Sall's avatar Mame Coumba Sall

Modified to revert back to revision before 34090


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34148 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8e501200
...@@ -48,13 +48,10 @@ from Products.ERP5.Document.File import File ...@@ -48,13 +48,10 @@ from Products.ERP5.Document.File import File
from Products.ERP5.Document.Document import PermanentURLMixIn from Products.ERP5.Document.Document import PermanentURLMixIn
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
from Products.ERP5.Document.Document import NotConvertedError from Products.ERP5.Document.Document import NotConvertedError
from AccessControl.SecurityManagement import getSecurityManager
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
# Mixin Import # Mixin Import
from Products.ERP5.mixin.cached_convertable import CachedConvertableMixin from Products.ERP5.mixin.cached_convertable import CachedConvertableMixin
from Products.ERP5.mixin.convertable import ConvertableMixin
from Products.ERP5.mixin.base_convertable import BaseConvertableMixin
enc=base64.encodestring enc=base64.encodestring
dec=base64.decodestring dec=base64.decodestring
...@@ -91,7 +88,7 @@ class TimeoutTransport(SafeTransport): ...@@ -91,7 +88,7 @@ class TimeoutTransport(SafeTransport):
return SafeTransport.make_connection(self, h) return SafeTransport.make_connection(self, h)
class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertableMixin, ConvertableMixin): class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin):
""" """
A file document able to convert OOo compatible files to A file document able to convert OOo compatible files to
any OOo supported format, to capture metadata and to any OOo supported format, to capture metadata and to
...@@ -187,7 +184,9 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab ...@@ -187,7 +184,9 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab
_setCacheHeaders(_ViewEmulator().__of__(self), {'format' : format}) _setCacheHeaders(_ViewEmulator().__of__(self), {'format' : format})
# Verify that the format is acceptable (from permission point of view) # Verify that the format is acceptable (from permission point of view)
if self.isTargetFormatPermitted(format)==False: method = self._getTypeBasedMethod('checkConversionFormatPermission',
fallback_script_id = 'Document_checkConversionFormatPermission')
if not method(format=format):
raise Unauthorized("OOoDocument: user does not have enough permission to access document" raise Unauthorized("OOoDocument: user does not have enough permission to access document"
" in %s format" % (format or 'original')) " in %s format" % (format or 'original'))
...@@ -280,7 +279,8 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab ...@@ -280,7 +279,8 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab
allowed = server_proxy.getAllowedTargets(content_type) allowed = server_proxy.getAllowedTargets(content_type)
warn('Your oood version is too old, using old method ' warn('Your oood version is too old, using old method '
'getAllowedTargets instead of getAllowedTargetList', 'getAllowedTargets instead of getAllowedTargetList',
DeprecationWarning) DeprecationWarning)
# tuple order is reversed to be compatible with ERP5 Form # tuple order is reversed to be compatible with ERP5 Form
return [(y, x) for x, y in allowed] return [(y, x) for x, y in allowed]
...@@ -313,11 +313,10 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab ...@@ -313,11 +313,10 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab
def isTargetFormatAllowed(self, format): def isTargetFormatAllowed(self, format):
""" """
Checks if the current document can be converted Checks if the current document can be converted
into the specified target format into the specified target format.
""" """
return format in self.getTargetFormatList() return format in self.getTargetFormatList()
security.declarePrivate('_convert') security.declarePrivate('_convert')
def _convert(self, format): def _convert(self, format):
""" """
...@@ -410,10 +409,6 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab ...@@ -410,10 +409,6 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab
# Raise an error if the format is not supported # Raise an error if the format is not supported
if not self.isTargetFormatAllowed(format): if not self.isTargetFormatAllowed(format):
raise ConversionError("OOoDocument: target format %s is not supported" % format) raise ConversionError("OOoDocument: target format %s is not supported" % format)
# Raise an error if the format is not permitted
if not self.isTargetFormatPermitted(format):
raise Unauthorized("OOoDocument: user does not have enough permission to access document"
" in %s format" % (format or 'original'))
# Check if we have already a base conversion # Check if we have already a base conversion
if not self.hasBaseData(): if not self.hasBaseData():
raise NotConvertedError raise NotConvertedError
...@@ -558,13 +553,13 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab ...@@ -558,13 +553,13 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertab
metadata = response_dict['meta'] metadata = response_dict['meta']
self._base_metadata = metadata self._base_metadata = metadata
if metadata.get('MIMEType', None) is not None: if metadata.get('MIMEType', None) is not None:
self._setBaseContentType(metadata['MIMEType']) self._setBaseContentType(metadata['MIMEType'])
else: else:
# Explicitly raise the exception! # Explicitly raise the exception!
raise ConversionError( raise ConversionError(
"OOoDocument: Error converting document to base format %s:%s:" "OOoDocument: Error converting document to base format %s:%s:"
% (response_code, response_message)) % (response_code, response_message))
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getContentInformation') 'getContentInformation')
def getContentInformation(self): def getContentInformation(self):
......
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