From c81c0fbe731d74d1fbd6066c20149c35179c7170 Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Tue, 11 Mar 2008 14:02:05 +0000
Subject: [PATCH] Make permanentURL system usable in standard ERP5.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19793 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Document.py   | 41 +++++++++++++++++++++++++++++
 product/ERP5/Document/WebSection.py | 39 ---------------------------
 2 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/product/ERP5/Document/Document.py b/product/ERP5/Document/Document.py
index d532530fb2..f33907754e 100644
--- a/product/ERP5/Document/Document.py
+++ b/product/ERP5/Document/Document.py
@@ -232,6 +232,9 @@ class PermanentURLMixIn(ExtensibleTraversableMixIn):
     can also use the permanent URL principle.
   """
 
+  # Declarative security
+  security = ClassSecurityInfo()
+
   ### Extensible content
   def _getExtensibleContent(self, request, name):
     # Permanent URL traversal
@@ -289,6 +292,44 @@ class PermanentURLMixIn(ExtensibleTraversableMixIn):
                                             editable_absolute_url=document.absolute_url()))
       return document.__of__(self)
 
+  security.declareProtected(Permissions.View, 'getDocumentValue')
+  def getDocumentValue(self, name=None, portal=None, **kw):
+    """
+      Return the default document with the given
+      name. The name parameter may represent anything
+      such as a document reference, an identifier,
+      etc.
+
+      If name is not provided, the method defaults
+      to returning the default document by calling
+      getDefaultDocumentValue.
+
+      kw parameters can be useful to filter content
+      (ex. force a given validation state)
+
+      This method must be implemented through a
+      portal type dependent script:
+        WebSection_getDocumentValue
+    """
+    if name is None:
+      return self.getDefaultDocumentValue()
+
+    cache = getReadOnlyTransactionCache(self)
+    method = None
+    if cache is not None:
+      key = ('getDocumentValue', self)
+      try:
+        method = cache[key]
+      except KeyError:
+        pass
+
+    if method is None: method = self._getTypeBasedMethod('getDocumentValue',
+                                      fallback_script_id='WebSection_getDocumentValue')
+
+    if cache is not None:
+      if cache.get(key, _MARKER) is _MARKER: cache[key] = method
+
+    return method(name, portal=portal, **kw)
 
 class Document(PermanentURLMixIn, XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
   """
diff --git a/product/ERP5/Document/WebSection.py b/product/ERP5/Document/WebSection.py
index 693d1734fd..a97caf65bc 100644
--- a/product/ERP5/Document/WebSection.py
+++ b/product/ERP5/Document/WebSection.py
@@ -175,45 +175,6 @@ class WebSection(Domain, PermanentURLMixIn):
       return self.getContainerLayout()
 
     # WebSection API
-    security.declareProtected(Permissions.View, 'getDocumentValue')
-    def getDocumentValue(self, name=None, portal=None, **kw):
-      """
-        Return the default document with the given
-        name. The name parameter may represent anything
-        such as a document reference, an identifier,
-        etc.
-
-        If name is not provided, the method defaults
-        to returning the default document by calling
-        getDefaultDocumentValue.
-
-        kw parameters can be useful to filter content
-        (ex. force a given validation state)
-
-        This method must be implemented through a
-        portal type dependent script:
-          WebSection_getDocumentValue
-      """
-      if name is None:
-        return self.getDefaultDocumentValue()
-
-      cache = getReadOnlyTransactionCache(self)
-      method = None
-      if cache is not None:
-        key = ('getDocumentValue', self)
-        try:
-          method = cache[key]
-        except KeyError:
-          pass
-
-      if method is None: method = self._getTypeBasedMethod('getDocumentValue',
-                                        fallback_script_id='WebSection_getDocumentValue')
-
-      if cache is not None:
-        if cache.get(key, MARKER) is MARKER: cache[key] = method
-
-      return method(name, portal=portal, **kw)
-
     security.declareProtected(Permissions.View, 'getDefaultDocumentValue')
     def getDefaultDocumentValue(self):
       """
-- 
2.30.9