[Erp5-report] r19592 - /erp5/trunk/products/ERP5Type/Base.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Feb 29 15:37:14 CET 2008


Author: kazuhiko
Date: Fri Feb 29 15:37:13 2008
New Revision: 19592

URL: http://svn.erp5.org?rev=19592&view=rev
Log:
revise the implementation of getting the root document path.

Modified:
    erp5/trunk/products/ERP5Type/Base.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=19592&r1=19591&r2=19592&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Fri Feb 29 15:37:13 2008
@@ -2713,30 +2713,22 @@
       self.activate(group_method_id='portal_catalog/catalogObjectList', 
                     alternate_method_id='alternateReindexObject',
                     group_id=group_id,
-                    serialization_tag=self.getRootDocument(),
+                    serialization_tag=self.getRootDocumentPath(),
                     **activate_kw).immediateReindexObject(**kw)
 
   security.declarePublic('recursiveReindexObject')
   recursiveReindexObject = reindexObject
 
-  def getRootDocument(self):
-    result = self.getRootDocumentValue()
-    if result is not None:
-      result = result.getPath()
-    return result
-    
-  def getRootDocumentValue(self):
-    result = None
-    parent_value = self.getParentValue()
-    if parent_value is not None:
-      parent_id = parent_value.getId()
-      if parent_id.endswith('_module') or parent_id.startswith('portal_'):
-        result = self
-      else:
-        getRootDocumentValue = getattr(parent_value, 'getRootDocumentValue', None)
-        if getRootDocumentValue is not None:
-          result = getRootDocumentValue()
-    return result
+  def getRootDocumentPath(self):
+    # if document, return the path of its root document
+    # otherwire, return None
+    self_path_list = self.getPhysicalPath()
+    self_depth = len(self_path_list)
+    portal_depth = len(self.getPortalObject().getPhysicalPath())
+    if self_depth > portal_depth + 1:
+      return '/'.join(self_path_list[:portal_depth + 2])
+    else:
+      return None
 
   security.declareProtected( Permissions.AccessContentsInformation, 'getIndexableChildValueList' )
   def getIndexableChildValueList(self):




More information about the Erp5-report mailing list