r252722 - atreal.multipubli/trunk/atreal/multipubli/content
"Florent MICHON" <svn-changes-z4DKO/[email protected]> Tue, 17 Dec 2013 15:05:59 +0000 (UTC)
| Newsgroups | gmane.comp.web.zope.plone.collective.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: f10w
Date: Tue Dec 17 15:05:58 2013
New Revision: 252722
Modified:
atreal.multipubli/trunk/atreal/multipubli/content/ulink.py
Log:
Fix the default view when the ulink is a file
Modified: atreal.multipubli/trunk/atreal/multipubli/content/ulink.py
==============================================================================
--- atreal.multipubli/trunk/atreal/multipubli/content/ulink.py (original)
+++ atreal.multipubli/trunk/atreal/multipubli/content/ulink.py Tue Dec 17 15:05:58 2013
@@ -30,6 +30,7 @@
from Products.Archetypes.BaseContent import BaseContent
from Products.ATContentTypes.content.base import registerATCT
from Products.ATContentTypes.content.base import ATCTContent
+from Products.ATContentTypes.content.base import ATCTFileContent
from Products.ATContentTypes.content.schemata import ATContentTypeSchema
from Products.ATContentTypes.content.schemata import finalizeATCTSchema
@@ -129,7 +130,29 @@
('location', None, "getLocation"),
('ModificationDate', None, "modified"))
-
+ inlineMimetypes= ('application/msword',
+ 'application/x-msexcel', # ?
+ 'application/vnd.ms-excel',
+ 'application/vnd.ms-powerpoint',
+ 'application/pdf',
+ 'application/x-shockwave-flash')
+
+ security.declareProtected(View, 'index_html')
+ def index_html(self, REQUEST=None, RESPONSE=None):
+ """Download the file
+ """
+ field = self.getPrimaryField()
+ if field.type == 'file':
+ source = self.getSource()
+ if field.getContentType(source) in self.inlineMimetypes:
+ # return the PDF and Office file formats inline
+ return ATCTFileContent.index_html(source, REQUEST, RESPONSE)
+ # otherwise return the content as an attachment
+ # Please note that text/* cannot be returned inline as
+ # this is a security risk (IE renders anything as HTML).
+ return field.download(source)
+ else:
+ return RESPONSE.redirect(self.absolute_url() + '/view')
def getIcon(self, relative_to_portal=0):
"""
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk