Commit 87224116 authored by Nicolas Delaby's avatar Nicolas Delaby

Guess portal_type only once

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24478 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 72af3bd9
...@@ -202,19 +202,11 @@ class ContributionTool(BaseTool): ...@@ -202,19 +202,11 @@ class ContributionTool(BaseTool):
if file is None: if file is None:
raise ValueError, "could not determine portal type" raise ValueError, "could not determine portal type"
# So we will simulate WebDAV to get an empty object
# with PUT_factory - we provide the mime_type as
# parameter
# LOG('new content', 0, "%s -- %s" % (file_name, mime_type))
# #
# Check if same file is already exists. if it exists, then update it. # Check if same file is already exists. if it exists, then update it.
# #
if portal_type is None: if portal_type is None:
registry = getToolByName(self, 'portal_contribution_registry', None) portal_type = self._guessPortalType(file_name, mime_type, data)
if registry is not None:
portal_type = registry.findPortalTypeName(file_name, None, data)
property_dict = self.getMatchedFileNamePatternDict(file_name) property_dict = self.getMatchedFileNamePatternDict(file_name)
reference = property_dict.get('reference', None) reference = property_dict.get('reference', None)
version = property_dict.get('version', None) version = property_dict.get('version', None)
...@@ -243,10 +235,6 @@ class ContributionTool(BaseTool): ...@@ -243,10 +235,6 @@ class ContributionTool(BaseTool):
extension = '.%s' % file_name.split('.')[-1] extension = '.%s' % file_name.split('.')[-1]
file_name = '%s%s' % (self.generateNewId(), extension) file_name = '%s%s' % (self.generateNewId(), extension)
# Try to guess the portal if it is not passed as parameter
if portal_type is None:
portal_type = self._guessPortalType(file_name, mime_type, data)
# Then put the file inside ourselves for a short while # Then put the file inside ourselves for a short while
if container_path is not None: if container_path is not None:
container = self.getPortalObject().restrictedTraverse(container_path) container = self.getPortalObject().restrictedTraverse(container_path)
......
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