Commit f05aab2a authored by Lucas Carvalho's avatar Lucas Carvalho

portal contributions does the same and much more, so we must use it.

parent bb106904
...@@ -65,7 +65,6 @@ def WebSection_setObject(self, id, ob, **kw): ...@@ -65,7 +65,6 @@ def WebSection_setObject(self, id, ob, **kw):
""" """
Add any change of the file uploaded. Add any change of the file uploaded.
""" """
sha512sum = hashlib.sha512() sha512sum = hashlib.sha512()
self.REQUEST._file.seek(0) self.REQUEST._file.seek(0)
while True: while True:
...@@ -93,26 +92,9 @@ def WebSection_putFactory(self, name, typ, body): ...@@ -93,26 +92,9 @@ def WebSection_putFactory(self, name, typ, body):
The key is the file name. The key is the file name.
""" """
portal = self.getPortalObject() portal = self.getPortalObject()
group = ('networkcache',) document = portal.portal_contributions.newContent(data=body,
new_id = str(portal.portal_ids.generateNewId(id_group=group)) filename=name,
registry = portal.portal_contribution_registry discover_metadata=False)
portal_type = registry.findPortalTypeName(filename=name,
content_type=typ)
if portal_type is None:
return None
# The code bellow is inspired from ERP5Type.Core.Folder.newContent
pt = self._getTypesTool()
myType = pt.getTypeInfo(self)
if myType is not None and not myType.allowType( portal_type ) and \
'portal_contributions' not in self.getPhysicalPath():
raise ValueError('Disallowed subobject type: %s' % portal_type)
container = portal.getDefaultModule(portal_type)
pt.constructContent(type_name=portal_type,
container=container,
id=new_id)
document = container._getOb(new_id)
# We can only change the state of the object after all the activities and # We can only change the state of the object after all the activities and
# interaction workflow, to avoid any security problem. # interaction workflow, to avoid any security problem.
......
40 41
\ No newline at end of file \ No newline at end of file
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