[Erp5-report] r32051 nicolas - in /erp5/trunk/products/ERP5: Document/ Tool/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jan 28 10:59:04 CET 2010
Author: nicolas
Date: Thu Jan 28 10:59:03 2010
New Revision: 32051
URL: http://svn.erp5.org?rev=32051&view=rev
Log:
Remove method inspection and fallback to standard API
* The purpose of this special argument set_filename__ was
to avoid overloading the filename provided by the user in by File._edit
* Small typo refactoring
Reviewed by Jerome
Modified:
erp5/trunk/products/ERP5/Document/File.py
erp5/trunk/products/ERP5/Tool/ContributionTool.py
Modified: erp5/trunk/products/ERP5/Document/File.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/File.py?rev=32051&r1=32050&r2=32051&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/File.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/File.py [utf8] Thu Jan 28 10:59:03 2010
@@ -103,19 +103,18 @@
### Special edit method
security.declarePrivate( '_edit' )
- def _edit(self, set_filename__=1, **kw):
- """\
+ def _edit(self, **kw):
+ """
This is used to edit files
"""
if kw.has_key('file'):
file = kw.get('file')
precondition = kw.get('precondition')
- if set_filename__:
- filename = getattr(file, 'filename', None)
- # if file field is empty(no file is uploaded),
- # filename is empty string.
- if filename not in (None, ''):
- self._setSourceReference(filename)
+ filename = getattr(file, 'filename', None)
+ # if file field is empty(no file is uploaded),
+ # filename is empty string.
+ if filename:
+ self._setSourceReference(filename)
if self._isNotEmpty(file):
self._setFile(file, precondition=precondition)
del kw['file']
Modified: erp5/trunk/products/ERP5/Tool/ContributionTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/ContributionTool.py?rev=32051&r1=32050&r2=32051&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/ContributionTool.py [utf8] Thu Jan 28 10:59:03 2010
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved.
@@ -32,7 +33,6 @@
import socket
import md5
import urllib2, urllib
-import inspect
from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.ERP5Type.Globals import InitializeClass, DTMLFile
@@ -128,10 +128,14 @@
We always generate ID. So, we must prevent using the one
which we were provided.
"""
- if file_name is not None: kw['file_name'] = file_name
- if data is not None: kw['data'] = data # This is only used to make sure
- # we can pass file as parameter to ZPublisher
- # whenever we ingest email
+ user_filename = file_name # store original filename
+ if file_name is not None:
+ kw['file_name'] = file_name
+ if data is not None:
+ # This is only used to make sure
+ # we can pass file as parameter to ZPublisher
+ # whenever we ingest email
+ kw['data'] = data
# Temp objects use the standard newContent from Folder
if temp_object:
# For temp_object creation, use the standard method
@@ -240,12 +244,13 @@
kw.update(modified_kw)
# Then edit the document contents (so that upload can happen)
- if 'set_filename__' in inspect.getargspec(document._edit)[0]:
- # Only a few classes supports set_filename__.
- document._edit(set_filename__=0, **kw)
+ document._edit(**kw)
+ if getattr(document, 'guessMimeType', None) is not None:
+ # For File force to setup the mime_type
document.guessMimeType(fname=file_name)
- else:
- document._edit(**kw)
+ if user_filename:
+ # Restore the Original filename pass by the user
+ document.setSourceReference(user_filename)
if url:
document.fromURL(url)
More information about the Erp5-report
mailing list