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, ...@@ -2463,6 +2463,14 @@ class Base( CopyContainer,
def _temp_setUid(self, value): def _temp_setUid(self, value):
self.uid = value # Required for Listbox so that no casting happens when we use TempBase to create new objects 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): def _temp_setTitle(self, value):
""" """
Required so that getProperty('title') will work on tempBase objects Required so that getProperty('title') will work on tempBase objects
......
...@@ -355,13 +355,13 @@ class TempDocumentConstructor(DocumentConstructor): ...@@ -355,13 +355,13 @@ class TempDocumentConstructor(DocumentConstructor):
# Replace some attributes. # Replace some attributes.
for name in ('isIndexable', 'reindexObject', 'recursiveReindexObject', for name in ('isIndexable', 'reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle'): 'activate', 'setUid', 'setTitle', 'getTitle', 'getUid'):
setattr(TempDocument, name, getattr(klass, '_temp_%s' % name)) setattr(TempDocument, name, getattr(klass, '_temp_%s' % name))
# Make some methods public. # Make some methods public.
for method_id in ('reindexObject', 'recursiveReindexObject', for method_id in ('reindexObject', 'recursiveReindexObject',
'activate', 'setUid', 'setTitle', 'getTitle', 'activate', 'setUid', 'setTitle', 'getTitle',
'edit', 'setProperty'): 'edit', 'setProperty', 'getUid'):
setattr(TempDocument, '%s__roles__' % method_id, None) setattr(TempDocument, '%s__roles__' % method_id, None)
self.klass = TempDocument 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