diff --git a/bt5/erp5_web_shacache/ExtensionTemplateItem/ShaCache.py b/bt5/erp5_web_shacache/ExtensionTemplateItem/ShaCache.py index bcb75d30f8a32fc58b69dde5234d6b4bcb863421..f2955971197dc85a75ff903d4b2ba0faa414b461 100644 --- a/bt5/erp5_web_shacache/ExtensionTemplateItem/ShaCache.py +++ b/bt5/erp5_web_shacache/ExtensionTemplateItem/ShaCache.py @@ -35,11 +35,6 @@ def WebSection_getDocumentValue(self, key, portal=None, language=None,\ """ API SHACACHE - - POST /<key> - + parameters required: - * data: it is the file content - The key is the file name. - - GET /<key> The key is the sha512sum. @@ -70,9 +65,6 @@ def WebSection_setObject(self, id, ob, **kw): """ Add any change of the file uploaded. """ - ob.publishAlive() - ob.setContentType('application/octet-stream') - ob.setFilename(id) sha512sum = hashlib.sha512() self.REQUEST._file.seek(0) @@ -86,12 +78,19 @@ def WebSection_setObject(self, id, ob, **kw): if reference != id: raise ValueError('The content does not match with sha512sum provided.') + # Set object properties + ob.setContentType('application/octet-stream') + ob.setFilename(id) ob.setReference(reference) return ob def WebSection_putFactory(self, name, typ, body): """ - XXX + API SHACACHE + - PUT /<key> + + parameters required: + * data: it is the file content + The key is the file name. """ portal = self.getPortalObject() group = ('networkcache',) @@ -114,4 +113,12 @@ def WebSection_putFactory(self, name, typ, body): id=new_id) document = container._getOb(new_id) + + # We can only change the state of the object after all the activities and + # interaction workflow, to avoid any security problem. + document.activate(after_path_and_method_id=(document.getPath(), \ + ('convertToBaseFormat', 'Document_tryToConvertToBaseFormat', \ + 'immediateReindexObject', 'recursiveImmediateReindexObject')))\ + .WebSite_publishDocumentByActivity() + return document diff --git a/bt5/erp5_web_shacache/bt/revision b/bt5/erp5_web_shacache/bt/revision index dce6588ca1420a69eea5699f2ec5d666daf16a6a..7c091989d018956d085a80a955a265ebbb0d0a49 100644 --- a/bt5/erp5_web_shacache/bt/revision +++ b/bt5/erp5_web_shacache/bt/revision @@ -1 +1 @@ -36 \ No newline at end of file +37 \ No newline at end of file