Commit 6830a0f8 authored by Vincent Pelletier's avatar Vincent Pelletier

Prevent UIDs from being generated on temp objects by overriding the getUid...

Prevent UIDs from being generated on temp objects by overriding the getUid accessor. Provide the Id as a fallback.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15168 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9fe3a03d
......@@ -2463,6 +2463,14 @@ class Base( CopyContainer,
def _temp_setUid(self, value):
self.uid = value # Required for Listbox so that no casting happens when we use TempBase to create new objects
def _temp_getUid(self):
try:
return getattr(aq_base(self), 'uid')
except AttributeError:
value = self.getId()
self.setUid(value)
return value
def _temp_setTitle(self, value):
"""
Required so that getProperty('title') will work on tempBase objects
......
......@@ -355,13 +355,13 @@ class TempDocumentConstructor(DocumentConstructor):
# Replace some attributes.
for name in ('isIndexable', 'reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle'):
'activate', 'setUid', 'setTitle', 'getTitle', 'getUid'):
setattr(TempDocument, name, getattr(klass, '_temp_%s' % name))
# Make some methods public.
for method_id in ('reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle',
'edit', 'setProperty'):
'edit', 'setProperty', 'getUid'):
setattr(TempDocument, '%s__roles__' % method_id, None)
self.klass = TempDocument
......
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