Commit abcb2c6e authored by Jean-Paul Smets's avatar Jean-Paul Smets

Use PermanentURLMixIn to provide permanent URL access everywhere.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19520 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7c6f707a
...@@ -34,11 +34,14 @@ from xmlrpclib import SafeTransport ...@@ -34,11 +34,14 @@ from xmlrpclib import SafeTransport
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl import Unauthorized from AccessControl import Unauthorized
from OFS.Image import Pdata from OFS.Image import Pdata
from OFS.Image import File as OFSFile
from OFS.content_types import guess_content_type
from Products.CMFCore.utils import getToolByName, _setCacheHeaders from Products.CMFCore.utils import getToolByName, _setCacheHeaders
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5.Document.File import File from Products.ERP5.Document.File import File
from Products.ERP5.Document.Document import PermanentURLMixIn
from Products.ERP5.Document.Document import ConversionCacheMixin from Products.ERP5.Document.Document import ConversionCacheMixin
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
...@@ -73,7 +76,7 @@ class TimeoutTransport(SafeTransport): ...@@ -73,7 +76,7 @@ class TimeoutTransport(SafeTransport):
return SafeTransport.make_connection(self, h) return SafeTransport.make_connection(self, h)
class OOoDocument(File, ConversionCacheMixin): class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
""" """
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
...@@ -472,31 +475,24 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -472,31 +475,24 @@ class OOoDocument(File, ConversionCacheMixin):
file_name = f.filename file_name = f.filename
document = self.get(file_name, None) document = self.get(file_name, None)
if document is not None: if document is not None:
self.manage_delObjects([file_name]) self.manage_delObjects([file_name]) # For compatibility with old implementation
newContent = UnrestrictedMethod(self.portal_contributions.newContent)
if file_name.endswith('html'): if file_name.endswith('html'):
web_page = newContent(\ mime = 'text/html'
id=file_name, container=self, portal_type='Web Page', data = zip_file.read(file_name)
file_name=file_name,
data=zip_file.read(file_name))
if web_page.getValidationState() != 'embedded':
# Make sure embedded is set until cleaner solution if found
web_page.edit()
web_page.activate().discoverMetadata() # Maybe we should use contribution tool instead
# Should be embedded
else: else:
image_or_file = newContent(\ mime = guess_content_type(file_name)[0]
id=file_name, container=self, data = Pdata(zip_file.read(file_name))
portal_type='Image', # Contribution Tool would be better here self.setConversion(data, mime, format='_embedded', file_name=file_name)
file_name=file_name,
data=zip_file.read(file_name))
if image_or_file.getValidationState() != 'embedded':
# Make sure embedded is set until cleaner solution if found
image_or_file.edit()
if must_close: if must_close:
zip_file.close() zip_file.close()
archive_file.close() archive_file.close()
def _getExtensibleContent(self, request, name):
if self.hasConversion(format='_embedded', file_name=name):
mime, data = self.getConversion(format='_embedded', file_name=name)
return OFSFile(name, name, data, content_type=mime)
return PermanentURLMixIn._getExtensibleContent(self, request, name)
# Base format implementation # Base format implementation
security.declareProtected(Permissions.AccessContentsInformation, 'hasBaseData') security.declareProtected(Permissions.AccessContentsInformation, 'hasBaseData')
def hasBaseData(self): def hasBaseData(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