[Erp5-report] r44605 kazuhiko - in /erp5/trunk/products/ERP5: Document/ bootstrap/erp5_core...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 25 09:56:02 CET 2011


Author: kazuhiko
Date: Fri Mar 25 09:56:02 2011
New Revision: 44605

URL: http://svn.erp5.org?rev=44605&view=rev
Log:
reimplement 'keep_workflow_path_list' feature, because r42752 was done by the misunderstood idea. it should mean 'objects whose workflow history are exported', not 'existing objects whose workflow history should be kept'.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_view/my_template_keep_workflow_path_list.xml

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=44605&r1=44604&r2=44605&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Fri Mar 25 09:56:02 2011
@@ -563,7 +563,7 @@ class BaseTemplateItem(Implicit, Persist
     obj.__class__ = newklass
     return obj
 
-  def removeProperties(self, obj, export):
+  def removeProperties(self, obj, export, keep_workflow_history=False):
     """
     Remove unneeded properties for export
     """
@@ -572,8 +572,10 @@ class BaseTemplateItem(Implicit, Persist
     classname = klass.__name__
 
     attr_set = set(('_dav_writelocks', '_filepath', '_owner', 'uid',
-                    'workflow_history', '__ac_local_roles__'))
+                    '__ac_local_roles__'))
     if export:
+      if not keep_workflow_history:
+        attr_set.add('workflow_history')
       # PythonScript covers both Zope Python scripts
       # and ERP5 Python Scripts
       if isinstance(obj, PythonScript):
@@ -701,7 +703,8 @@ class ObjectTemplateItem(BaseTemplateIte
       relative_url = '/'.join([url,id])
       obj = p.unrestrictedTraverse(relative_url)
       obj = obj._getCopy(context)
-      obj = self.removeProperties(obj, 1)
+      keep_workflow_history = self.isKeepWorkflowObject(relative_url)
+      obj = self.removeProperties(obj, 1, keep_workflow_history)
       id_list = obj.objectIds() # FIXME duplicated variable name
       if hasattr(aq_base(obj), 'groups'): # XXX should check metatype instead
         # we must keep groups because they are deleted along with subobjects
@@ -728,7 +731,8 @@ class ObjectTemplateItem(BaseTemplateIte
       except AttributeError:
         raise AttributeError, "Could not find object '%s' during business template processing." % relative_url
       _recursiveRemoveUid(obj)
-      obj = self.removeProperties(obj, 1)
+      keep_workflow_history = self.isKeepWorkflowObject(relative_url)
+      obj = self.removeProperties(obj, 1, keep_workflow_history)
       id_list = obj.objectIds()
       if hasattr(aq_base(obj), 'groups'): # XXX should check metatype instead
         # we must keep groups because they are deleted along with subobjects
@@ -1020,7 +1024,6 @@ class ObjectTemplateItem(BaseTemplateIte
           saved_uid_dict = {}
           subobjects_dict = {}
           portal_type_dict = {}
-          workflow_history = None
           old_obj = container._getOb(object_id, None)
           object_existed = old_obj is not None
           if object_existed:
@@ -1047,11 +1050,6 @@ class ObjectTemplateItem(BaseTemplateIte
                 portal_type_dict[attr] = getattr(old_obj, attr, ())
               portal_type_dict['workflow_chain'] = \
                 getChainByType(context)[1].get('chain_' + object_id, '')
-            # try to keep workflow history for specified objects.
-            workflow_history = getattr(old_obj, 'workflow_history', None)
-            if workflow_history is not None \
-                   and context.isKeepWorkflowObject(path):
-                workflow_history = deepcopy(workflow_history)
             container.manage_delObjects([object_id])
 
           # install object
@@ -1100,7 +1098,11 @@ class ObjectTemplateItem(BaseTemplateIte
           # useless because we will already reindex every created object, so
           # we avoid duplication of reindexation
           obj.isIndexable = ConstantGetter('isIndexable', value=False)
+          # keep workflow history if exists
+          workflow_history = getattr(obj, 'workflow_history', None)
           obj.manage_afterClone(obj)
+          if workflow_history is not None:
+            setattr(obj, 'workflow_history', workflow_history)
           del obj.isIndexable
           if getattr(aq_base(obj), 'reindexObject', None) is not None:
             obj.reindexObject()
@@ -1131,9 +1133,6 @@ class ObjectTemplateItem(BaseTemplateIte
                 # an object which cannot (e.g. External Method).
                 LOG('BusinessTemplate', WARNING,
                     'could not restore %r in %r' % (subobject_id, obj))
-          # copy workflow history if required
-          if workflow_history is not None:
-            setattr(obj, 'workflow_history', workflow_history)
           if obj.meta_type in ('Z SQL Method',):
             fixZSQLMethod(portal, obj)
           # portal transforms specific initialization
@@ -1402,7 +1401,8 @@ class PathTemplateItem(ObjectTemplateIte
         obj = obj.__of__(context)
         _recursiveRemoveUid(obj)
         id_list = obj.objectIds()
-        obj = self.removeProperties(obj, 1)
+        keep_workflow_history = self.isKeepWorkflowObject(relative_url)
+        obj = self.removeProperties(obj, 1, keep_workflow_history)
         if hasattr(aq_base(obj), 'groups'):
           # we must keep groups because it's ereased when we delete subobjects
           groups = deepcopy(obj.groups)
@@ -1520,7 +1520,8 @@ class CategoryTemplateItem(ObjectTemplat
       relative_url = '/'.join([url,id])
       obj = p.unrestrictedTraverse(relative_url)
       obj = obj._getCopy(context)
-      obj = self.removeProperties(obj, 1)
+      keep_workflow_history = self.isKeepWorkflowObject(relative_url)
+      obj = self.removeProperties(obj, 1, keep_workflow_history)
       id_list = obj.objectIds()
       if id_list:
         self.build_sub_objects(context, id_list, relative_url)
@@ -1542,7 +1543,8 @@ class CategoryTemplateItem(ObjectTemplat
         else:
           raise ValueError, "%s not found" % relative_url
       _recursiveRemoveUid(obj)
-      obj = self.removeProperties(obj, 1)
+      keep_workflow_history = self.isKeepWorkflowObject(relative_url)
+      obj = self.removeProperties(obj, 1, keep_workflow_history)
       include_sub_categories = obj.__of__(context).getProperty('business_template_include_sub_categories', 0)
       id_list = obj.objectIds()
       if len(id_list) > 0 and include_sub_categories:
@@ -1905,7 +1907,9 @@ class PortalTypeTemplateItem(ObjectTempl
                                       'hidden_content_type_list',
                                       'property_sheet_list',
                                       'base_category_list',
-                                      'last_id', 'uid', 'workflow_history'):
+                                      'last_id', 'uid') or \
+            (attr == 'workflow_history' and
+             not self.isKeepWorkflowObject(relative_url)):
           delattr(obj, attr)
       self._objects[relative_url] = obj
       obj.wl_clearLocks()
@@ -2769,7 +2773,8 @@ class ActionTemplateItem(ObjectTemplateI
           continue
         raise NotFound('Action %r not found' % id)
       key = posixpath.join(url[-2], url[-1], value)
-      self._objects[key] = self.removeProperties(action, 1)
+      keep_workflow_history = self.isKeepWorkflowObject(key)
+      self._objects[key] = self.removeProperties(action, 1, keep_workflow_history)
       self._objects[key].wl_clearLocks()
 
   def install(self, context, trashbin, **kw):

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_view/my_template_keep_workflow_path_list.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_view/my_template_keep_workflow_path_list.xml?rev=44605&r1=44604&r2=44605&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_view/my_template_keep_workflow_path_list.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BusinessTemplate_view/my_template_keep_workflow_path_list.xml [utf8] Fri Mar 25 09:56:02 2011
@@ -267,7 +267,7 @@
                 </item>
                 <item>
                     <key> <string>title</string> </key>
-                    <value> <string>Paths of objects whose workflow histories should be kept</string> </value>
+                    <value> <string>Paths of objects whose workflow histories should be exported</string> </value>
                 </item>
                 <item>
                     <key> <string>unicode</string> </key>



More information about the Erp5-report mailing list