[Erp5-report] r9187 - in /erp5/trunk/products/ERP5OOo/Document: DMSFile.py OOoDocument.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sun Aug 13 18:25:04 CEST 2006
Author: bartek
Date: Sun Aug 13 18:25:01 2006
New Revision: 9187
URL: http://svn.erp5.org?rev=9187&view=rev
Log:
additional method for setting content_type of an object created by a script
Modified:
erp5/trunk/products/ERP5OOo/Document/DMSFile.py
erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
Modified: erp5/trunk/products/ERP5OOo/Document/DMSFile.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/Document/DMSFile.py?rev=9187&r1=9186&r2=9187&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/Document/DMSFile.py (original)
+++ erp5/trunk/products/ERP5OOo/Document/DMSFile.py Sun Aug 13 18:25:01 2006
@@ -34,6 +34,10 @@
from Products.ERP5Type.XMLObject import XMLObject
# to overwrite WebDAV methods
from Products.CMFDefault.File import File as CMFFile
+
+import mimetypes
+mimetypes.init()
+
class DMSFile(XMLObject,File):
"""
@@ -82,6 +86,16 @@
SearchableText=getSearchableText
+ security.declareProtected(Permissions.ModifyPortalContent, 'guessMimeType')
+ def guessMimeType(self,fname=''):
+ '''get mime type from file name'''
+ if fname=='':fname=self.getOriginalFilename()
+ if fname:
+ content_type,enc=mimetypes.guess_type(fname)
+ if content_type is not None:
+ self.content_type=content_type
+ return content_type
+
# BG copied from File in case
index_html = CMFFile.index_html
Modified: erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/Document/OOoDocument.py?rev=9187&r1=9186&r2=9187&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/Document/OOoDocument.py (original)
+++ erp5/trunk/products/ERP5OOo/Document/OOoDocument.py Sun Aug 13 18:25:01 2006
@@ -36,9 +36,11 @@
from Products.ERP5.Document.File import File
from Products.ERP5Type.XMLObject import XMLObject
from DateTime import DateTime
-import xmlrpclib, base64
+import xmlrpclib, base64, mimetypes
# to overwrite WebDAV methods
from Products.CMFDefault.File import File as CMFFile
+
+mimetypes.init()
enc=base64.encodestring
dec=base64.decodestring
@@ -495,6 +497,19 @@
s+='</table>'
return s
+ # this will go out after refactoring (will be inherited from DMS File
+ # and eventually from File
+ security.declareProtected(Permissions.ModifyPortalContent, 'guessMimeType')
+ def guessMimeType(self,fname=''):
+ '''get mime type from file name'''
+ if fname=='':fname=self.getOriginalFilename()
+ if fname:
+ content_type,enc=mimetypes.guess_type(fname)
+ if content_type is not None:
+ self.content_type=content_type
+ return content_type
+
+
# make sure to call the right edit methods
_edit=File._edit
edit=File.edit
More information about the Erp5-report
mailing list