Commit 01338ab2 authored by Romain Courteaud's avatar Romain Courteaud

Change code layout.

_edit does not call reindexObject anymore if no property is changed.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3702 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b9def522
...@@ -79,9 +79,10 @@ class WorkflowMethod(Method): ...@@ -79,9 +79,10 @@ class WorkflowMethod(Method):
if id is None: if id is None:
id = method.__name__ id = method.__name__
self._id = id self._id = id
def __call__(self, instance, *args, **kw):
""" Invoke the wrapped method, and deal with the results. def __call__(self, instance, *args, **kw):
"""
Invoke the wrapped method, and deal with the results.
""" """
wf = getToolByName(instance, 'portal_workflow', None) wf = getToolByName(instance, 'portal_workflow', None)
if wf is None or not hasattr(wf, 'wrapWorkflowMethod'): if wf is None or not hasattr(wf, 'wrapWorkflowMethod'):
...@@ -877,7 +878,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -877,7 +878,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
# Object attributes update method # Object attributes update method
security.declarePrivate( '_edit' ) security.declarePrivate( '_edit' )
def _edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw): def _edit(self, REQUEST=None, force_update=0, reindex_object=0, **kw):
""" """
Generic edit Method for all ERP5 object Generic edit Method for all ERP5 object
The purpose of this method is to update attributed, eventually do The purpose of this method is to update attributed, eventually do
...@@ -912,23 +913,36 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -912,23 +913,36 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
else: else:
old_value = None old_value = None
if old_value != kw[key] or force_update: if old_value != kw[key] or force_update:
self._v_modified_property_dict[key] = old_value # We keep in a thread var the previous values - this can be useful for interaction workflow to implement lookups # We keep in a thread var the previous values
# this can be useful for interaction workflow to implement lookups
self._v_modified_property_dict[key] = old_value
self._setProperty(key, kw[key]) self._setProperty(key, kw[key])
elif self.id != kw['id']: elif self.id != kw['id']:
self.recursiveFlushActivity(invoke=1) # Do not rename until everything flushed # XXX Do not rename until everything flushed
self.recursiveFlushActivity(invoke=1)
previous_relative_url = self.getRelativeUrl() previous_relative_url = self.getRelativeUrl()
self.aq_parent.manage_renameObjects([self.id], [kw['id']]) self.aq_parent.manage_renameObjects([self.id], [kw['id']])
new_relative_url = self.getRelativeUrl() new_relative_url = self.getRelativeUrl()
id_changed = 1 id_changed = 1
if reindex_object: self.reindexObject() if reindex_object:
# We do not want to reindex the object if nothing is changed
if (self._v_modified_property_dict != {}) or\
id_changed:
self.reindexObject()
if id_changed: if id_changed:
if reindex_object: self.flushActivity(invoke=1) # Required if we wish that news ids appear instantly if reindex_object:
# Required if we wish that news ids appear instantly
self.flushActivity(invoke=1)
#if self.isIndexable: #if self.isIndexable:
# self.moveObject() # Required if we wish that news ids appear instantly # Required if we wish that news ids appear instantly
# self.moveObject()
#if hasattr(aq_base(self), 'recursiveMoveObject'): #if hasattr(aq_base(self), 'recursiveMoveObject'):
# self.recursiveMoveObject() # Required to make sure path of subobjects is updated # Required to make sure path of subobjects is updated
self.activate().updateRelatedContent(previous_relative_url, new_relative_url) # self.recursiveMoveObject()
#self.activate().recursiveImmediateReindexObject() # Required to update path / relative_url of subobjects self.activate().updateRelatedContent(previous_relative_url,
new_relative_url)
# Required to update path / relative_url of subobjects
#self.activate().recursiveImmediateReindexObject()
security.declareProtected( Permissions.ModifyPortalContent, 'setId' ) security.declareProtected( Permissions.ModifyPortalContent, 'setId' )
def setId(self, id, reindex = 1): def setId(self, id, reindex = 1):
...@@ -949,11 +963,16 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -949,11 +963,16 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
""" """
self._getCategoryTool().updateRelatedContent(self, previous_category_url, new_category_url) self._getCategoryTool().updateRelatedContent(self, previous_category_url, new_category_url)
security.declareProtected( Permissions.ModifyPortalContent, 'edit' ) security.declareProtected(Permissions.ModifyPortalContent, 'edit')
def edit(self, REQUEST=None, force_update = 0, reindex_object=1, **kw): def edit(self, REQUEST=None, force_update=0, reindex_object=1, **kw):
return self._edit(REQUEST=REQUEST, force_update=force_update, reindex_object=reindex_object, **kw) """
Generic edit Method for all ERP5 object
"""
return self._edit(REQUEST=REQUEST, force_update=force_update,
reindex_object=reindex_object, **kw)
edit = WorkflowMethod( edit ) # XXX Is this useful ? (Romain)
edit = WorkflowMethod(edit)
# Accessing object property Ids # Accessing object property Ids
security.declareProtected( Permissions.View, 'getPropertyIdList' ) security.declareProtected( Permissions.View, 'getPropertyIdList' )
......
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