Commit ba85bd28 authored by Yusei Tahara's avatar Yusei Tahara

Use portal_contribution_registry instead of content_type_registry.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20591 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d1253bc5
...@@ -210,26 +210,27 @@ class ContributionTool(BaseTool): ...@@ -210,26 +210,27 @@ class ContributionTool(BaseTool):
# #
# 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:
content_type_registry = getToolByName(self, 'content_type_registry') registry = getToolByName(self, 'portal_contribution_registry', None)
portal_type = content_type_registry.findTypeName(file_name, None, None) if registry is not None:
property_dict = self.getMatchedFileNamePatternDict(file_name) portal_type = registry.findPortalTypeName(file_name, None, None)
reference = property_dict.get('reference', None) property_dict = self.getMatchedFileNamePatternDict(file_name)
version = property_dict.get('version', None) reference = property_dict.get('reference', None)
language = property_dict.get('language', None) version = property_dict.get('version', None)
if portal_type and reference and version and language: language = property_dict.get('language', None)
portal_catalog = getToolByName(self, 'portal_catalog') if portal_type and reference and version and language:
document = portal_catalog.getResultValue(portal_type=portal_type, portal_catalog = getToolByName(self, 'portal_catalog')
reference=reference, document = portal_catalog.getResultValue(portal_type=portal_type,
version=version, reference=reference,
language=language) version=version,
if document is not None: language=language)
# document is already uploaded. So overrides file. if document is not None:
if not _checkPermission(Permissions.ModifyPortalContent, document): # document is already uploaded. So overrides file.
raise Unauthorized, "[DMS] You are not allowed to update the existing document which has the same coordinates (id %s)" % document.getId() if not _checkPermission(Permissions.ModifyPortalContent, document):
document.edit(file=kw['file']) raise Unauthorized, "[DMS] You are not allowed to update the existing document which has the same coordinates (id %s)" % document.getId()
return document document.edit(file=kw['file'])
return document
# #
# Strong possibility of a new file. # Strong possibility of a new file.
...@@ -360,10 +361,8 @@ class ContributionTool(BaseTool): ...@@ -360,10 +361,8 @@ class ContributionTool(BaseTool):
(as long as the one we find is compatible) and move the (as long as the one we find is compatible) and move the
document to the appropriate module. document to the appropriate module.
content_type_registry must be set up so that an appropriate portal_contribution_registry will find appropriate portal type
portal_type with appropriate meta_type is found for every name by file_name and content itself.
kind of document. However, a different portal_type might
be used in the end.
The ContributionTool instance must be configured in such The ContributionTool instance must be configured in such
way that _verifyObjectPaste will return TRUE. way that _verifyObjectPaste will return TRUE.
......
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