[Erp5-report] r34093 mame - /erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Mar 25 13:21:27 CET 2010
Author: mame
Date: Thu Mar 25 13:21:26 2010
New Revision: 34093
URL: http://svn.erp5.org?rev=34093&view=rev
Log:
Modified to Verify that the format is acceptable
(from permission point of view)
Modified:
erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
Modified: erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/Document/OOoDocument.py?rev=34093&r1=34092&r2=34093&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/Document/OOoDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/Document/OOoDocument.py [utf8] Thu Mar 25 13:21:26 2010
@@ -48,10 +48,13 @@
from Products.ERP5.Document.Document import PermanentURLMixIn
from Products.ERP5.Document.Document import ConversionError
from Products.ERP5.Document.Document import NotConvertedError
+from AccessControl.SecurityManagement import getSecurityManager
from zLOG import LOG, ERROR
# Mixin Import
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
dec=base64.decodestring
@@ -88,7 +91,7 @@
return SafeTransport.make_connection(self, h)
-class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin):
+class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin, BaseConvertableMixin, ConvertableMixin):
"""
A file document able to convert OOo compatible files to
any OOo supported format, to capture metadata and to
@@ -184,9 +187,7 @@
_setCacheHeaders(_ViewEmulator().__of__(self), {'format' : format})
# Verify that the format is acceptable (from permission point of view)
- method = self._getTypeBasedMethod('checkConversionFormatPermission',
- fallback_script_id = 'Document_checkConversionFormatPermission')
- if not method(format=format):
+ if self.isTargetFormatPermitted(format)==False:
raise Unauthorized("OOoDocument: user does not have enough permission to access document"
" in %s format" % (format or 'original'))
@@ -279,8 +280,7 @@
allowed = server_proxy.getAllowedTargets(content_type)
warn('Your oood version is too old, using old method '
'getAllowedTargets instead of getAllowedTargetList',
- DeprecationWarning)
-
+ DeprecationWarning)
# tuple order is reversed to be compatible with ERP5 Form
return [(y, x) for x, y in allowed]
@@ -313,9 +313,10 @@
def isTargetFormatAllowed(self, format):
"""
Checks if the current document can be converted
- into the specified target format.
+ into the specified target format
"""
return format in self.getTargetFormatList()
+
security.declarePrivate('_convert')
def _convert(self, format):
@@ -409,6 +410,10 @@
# Raise an error if the format is not supported
if not self.isTargetFormatAllowed(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
if not self.hasBaseData():
raise NotConvertedError
@@ -553,13 +558,13 @@
metadata = response_dict['meta']
self._base_metadata = metadata
if metadata.get('MIMEType', None) is not None:
- self._setBaseContentType(metadata['MIMEType'])
+ self._setBaseContentType(metadata['MIMEType'])
else:
# Explicitly raise the exception!
raise ConversionError(
"OOoDocument: Error converting document to base format %s:%s:"
% (response_code, response_message))
-
+
security.declareProtected(Permissions.AccessContentsInformation,
'getContentInformation')
def getContentInformation(self):
More information about the Erp5-report
mailing list