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

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Mar 3 00:03:38 CET 2007


Author: jp
Date: Sat Mar  3 00:03:35 2007
New Revision: 13198

URL: http://svn.erp5.org?rev=13198&view=rev
Log:
Added getCompactTitle support (as well as getCompactLogicalPath) which is useful for sites were the depth of categories in large. Actually, this should be teh standard default everywhere. Also added some aggressive caching. Still to be discussed if it is that good or not.

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=13198&r1=13197&r2=13198&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Sat Mar  3 00:03:35 2007
@@ -1346,6 +1346,18 @@
       objectlist.append(objectlist[-1][element])
     return '/' + join([object.getTitle() for object in objectlist[1:]], '/')
 
+  security.declareProtected(Permissions.AccessContentsInformation, 'getCompactLogicalPath')
+  def getCompactLogicalPath(self, REQUEST=None) :
+    """
+      Returns a compact representation of the absolute path of an object
+      using compact titles when available
+    """
+    pathlist = self.getPhysicalPath()
+    objectlist = [self.getPhysicalRoot()]
+    for element in pathlist[1:] :
+      objectlist.append(objectlist[-1][element])
+    return '/' + join([object.getCompactTitle() for object in objectlist[1:]], '/')
+
   security.declareProtected(Permissions.AccessContentsInformation, 'getUrl')
   def getUrl(self, REQUEST=None):
     """
@@ -1871,6 +1883,21 @@
                             'getTranslatedShortTitleOrId')
   def getTranslatedShortTitleOrId(self):
     """
+    Returns the translated short title or the id if the id is empty
+    """
+    title = self.getTranslatedShortTitle()
+    if title is not None:
+      title = str(title)
+      if title == '' or title is None:
+        return self.getId()
+      else:
+        return title
+    return self.getId()
+
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'getTranslatedTitleOrId')
+  def getTranslatedTitleOrId(self):
+    """
     Returns the translated title or the id if the id is empty
     """
     title = self.getTranslatedTitle()
@@ -1883,18 +1910,21 @@
     return self.getId()
 
   security.declareProtected(Permissions.AccessContentsInformation,
-                            'getTranslatedTitleOrId')
-  def getTranslatedTitleOrId(self):
-    """
-    Returns the translated title or the id if the id is empty
-    """
-    title = self.getTranslatedTitle()
-    if title is not None:
-      title = str(title)
-      if title == '' or title is None:
-        return self.getId()
-      else:
-        return title
+                            'getCompactTitle')
+  def getCompactTitle(self):
+    """
+    Returns the translated short title or the reference or
+    the translated title or the ID by order of priority
+
+    NOTE: It could be useful to make this method overridable
+    with a type methode.
+    """
+    if self.hasShortTitle():
+      return self.getTranslatedShortTitle()
+    if self.hasReference():
+      return self.getReference()
+    if self.hasTitle():
+      return self.getTranslatedTitle()
     return self.getId()
 
   # This method allows to sort objects in list is a more reasonable way




More information about the Erp5-report mailing list