From ba85bd2838771762085e9cdfd5cb42c1c72e3121 Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Wed, 16 Apr 2008 18:10:37 +0000 Subject: [PATCH] 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 --- product/ERP5/Tool/ContributionTool.py | 45 +++++++++++++-------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/product/ERP5/Tool/ContributionTool.py b/product/ERP5/Tool/ContributionTool.py index d01d54be71..c6f8619dee 100644 --- a/product/ERP5/Tool/ContributionTool.py +++ b/product/ERP5/Tool/ContributionTool.py @@ -210,26 +210,27 @@ class ContributionTool(BaseTool): # # Check if same file is already exists. if it exists, then update it. - # + # if portal_type is None: - content_type_registry = getToolByName(self, 'content_type_registry') - portal_type = content_type_registry.findTypeName(file_name, None, None) - property_dict = self.getMatchedFileNamePatternDict(file_name) - reference = property_dict.get('reference', None) - version = property_dict.get('version', None) - language = property_dict.get('language', None) - if portal_type and reference and version and language: - portal_catalog = getToolByName(self, 'portal_catalog') - document = portal_catalog.getResultValue(portal_type=portal_type, - reference=reference, - version=version, - language=language) - if document is not None: - # document is already uploaded. So overrides file. - if not _checkPermission(Permissions.ModifyPortalContent, document): - raise Unauthorized, "[DMS] You are not allowed to update the existing document which has the same coordinates (id %s)" % document.getId() - document.edit(file=kw['file']) - return document + registry = getToolByName(self, 'portal_contribution_registry', None) + if registry is not None: + portal_type = registry.findPortalTypeName(file_name, None, None) + property_dict = self.getMatchedFileNamePatternDict(file_name) + reference = property_dict.get('reference', None) + version = property_dict.get('version', None) + language = property_dict.get('language', None) + if portal_type and reference and version and language: + portal_catalog = getToolByName(self, 'portal_catalog') + document = portal_catalog.getResultValue(portal_type=portal_type, + reference=reference, + version=version, + language=language) + if document is not None: + # document is already uploaded. So overrides file. + if not _checkPermission(Permissions.ModifyPortalContent, document): + raise Unauthorized, "[DMS] You are not allowed to update the existing document which has the same coordinates (id %s)" % document.getId() + document.edit(file=kw['file']) + return document # # Strong possibility of a new file. @@ -360,10 +361,8 @@ class ContributionTool(BaseTool): (as long as the one we find is compatible) and move the document to the appropriate module. - content_type_registry must be set up so that an appropriate - portal_type with appropriate meta_type is found for every - kind of document. However, a different portal_type might - be used in the end. + portal_contribution_registry will find appropriate portal type + name by file_name and content itself. The ContributionTool instance must be configured in such way that _verifyObjectPaste will return TRUE. -- 2.30.9