Commit fb49fda8 authored by Nicolas Delaby's avatar Nicolas Delaby

Resurect support of WebDAV on ContributionTool

If _setObject receive an object in ob parameter,
fill in the volatile cache and return the object.
Otherwise create new Document (like it is currently done)



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41663 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 488d4a0c
...@@ -342,52 +342,53 @@ class ContributionTool(BaseTool): ...@@ -342,52 +342,53 @@ class ContributionTool(BaseTool):
# document inside us at this stage. Else we # document inside us at this stage. Else we
# must find out where to store it. # must find out where to store it.
if ob is not None: if ob is not None:
# Call from webdav API # Called from webdav API
# redefine parameters # Object is already created by PUT_factory
portal_type = ob.getPortalType() # fill the volatile cache _v_document_cache
container = ob.getParentValue() # then return the document
if not portal_type: document = ob
document = BaseTool.newContent(self, id=id,
portal_type=portal_type,
is_indexable=0)
else: else:
# We give the system a last chance to analyse the if not portal_type:
# portal_type based on the document content document = BaseTool.newContent(self, id=id,
# (ex. a Memo is a kind of Text which can be identified portal_type=portal_type,
# by the fact it includes some specific content) is_indexable=0)
elif ob is None:
# Now we know the portal_type, let us find the module # We give the system a last chance to analyse the
# to which we should move the document to # portal_type based on the document content
if container is None: # (ex. a Memo is a kind of Text which can be identified
module = self.getDefaultModule(portal_type) # by the fact it includes some specific content)
else:
module = container # Now we know the portal_type, let us find the module
# There is no preexisting document - we can therefore # to which we should move the document to
# set the new object if container is None:
new_content_kw = {'portal_type': portal_type, module = self.getDefaultModule(portal_type)
'is_indexable': False} else:
if id is not None: module = container
new_content_kw['id'] = id # There is no preexisting document - we can therefore
document = module.newContent(**new_content_kw) # set the new object
# We can now discover metadata new_content_kw = {'portal_type': portal_type,
if discover_metadata: 'is_indexable': False}
# Metadata disovery is done as an activity by default if id is not None:
# If we need to discoverMetadata synchronously, it must new_content_kw['id'] = id
# be for user interface and should thus be handled by document = module.newContent(**new_content_kw)
# ZODB scripts # We can now discover metadata
document.activate(after_path_and_method_id=(document.getPath(), if discover_metadata:
('convertToBaseFormat', 'Document_tryToConvertToBaseFormat'))) \ # Metadata disovery is done as an activity by default
.discoverMetadata(filename=filename, # If we need to discoverMetadata synchronously, it must
user_login=user_login, # be for user interface and should thus be handled by
input_parameter_dict=input_parameter_dict) # ZODB scripts
# Keep the document close to us - this is only useful for document.activate(after_path_and_method_id=(document.getPath(),
# file upload from webdav ('convertToBaseFormat', 'Document_tryToConvertToBaseFormat'))) \
volatile_cache = getattr(self, '_v_document_cache', None) .discoverMetadata(filename=filename,
if volatile_cache is None: user_login=user_login,
self._v_document_cache = {} input_parameter_dict=input_parameter_dict)
volatile_cache = self._v_document_cache # Keep the document close to us - this is only useful for
volatile_cache[document.getId()] = document.getRelativeUrl() # file upload from webdav
volatile_cache = getattr(self, '_v_document_cache', None)
if volatile_cache is None:
self._v_document_cache = {}
volatile_cache = self._v_document_cache
volatile_cache[document.getId()] = document.getRelativeUrl()
# Return document to newContent method # Return document to newContent method
return document return document
......
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