Commit 0d144633 authored by Yoshinori Okuji's avatar Yoshinori Okuji

TempDocumentConstructor now creates a new class at runtime. This was required...

TempDocumentConstructor now creates a new class at runtime. This was required to set permissions correctly in temporary objects..

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13867 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d81e7020
......@@ -347,12 +347,26 @@ class DocumentConstructor(Method):
class TempDocumentConstructor(DocumentConstructor):
def __init__(self, klass):
# Create a new class to set permissions specific to temporary objects.
class TempDocument(klass):
pass
# Replace some attributes.
for name in ('isIndexable', 'reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle'):
setattr(TempDocument, name, getattr(klass, '_temp_%s' % name))
# Make some methods public.
for method_id in ('reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle',
'edit', 'setProperty'):
setattr(TempDocument, '%s__roles__' % method_id, None)
self.klass = TempDocument
def __call__(self, folder, id, REQUEST=None, **kw):
o = self.klass(id)
# Monkey patch TempBase specific arguments
for k in ('isIndexable', 'reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle'):
setattr(o, k, getattr(o,"_temp_%s" % k))
if kw:
o.__of__(folder)._edit(force_update=1, **kw)
if hasattr(folder, 'isTempObject') and folder.isTempObject():
......
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