From e0bb4bdef28552ba4c244287bae356477c9e39f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@tiolive.com>
Date: Thu, 12 Mar 2015 15:22:51 +0000
Subject: [PATCH] erp5_web: use Base_getWebDocumentDrivenModificationDate to
 get last Modified Date

---
 ...e_getWebDocumentDrivenModificationDate.xml | 84 +++++++++++++++++++
 .../caching_policy_manager.xml                | 12 ++-
 2 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getWebDocumentDrivenModificationDate.xml

diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getWebDocumentDrivenModificationDate.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getWebDocumentDrivenModificationDate.xml
new file mode 100644
index 0000000000..aa1cd75254
--- /dev/null
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getWebDocumentDrivenModificationDate.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>from Products.ERP5Type.Cache import CachingMethod\n
+\n
+def getLatestModificationDate():\n
+  document = context.getPortalObject().portal_catalog(\n
+    portal_type=("Web Page", "Web Section", "Web Site", "Image"),\n
+    sort_on=((\'modification_date\', \'descending\'),),\n
+    select_list=(\'modification_date\',),\n
+    limit=1,\n
+    )\n
+  return document[0].modification_date\n
+\n
+getLatestModificationDate = CachingMethod(\n
+  getLatestModificationDate,\n
+  id="Base_getWebDocumentDrivenModificationDate",\n
+  cache_factory="erp5_content_short",\n
+  )\n
+\n
+return getLatestModificationDate()\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_getWebDocumentDrivenModificationDate</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_web/ToolTemplateItem/caching_policy_manager.xml b/bt5/erp5_web/ToolTemplateItem/caching_policy_manager.xml
index 90b619ed3d..190668f6f6 100644
--- a/bt5/erp5_web/ToolTemplateItem/caching_policy_manager.xml
+++ b/bt5/erp5_web/ToolTemplateItem/caching_policy_manager.xml
@@ -255,7 +255,7 @@
                             </item>
                             <item>
                                 <key> <string>_max_age_secs</string> </key>
-                                <value> <int>300</int> </value>
+                                <value> <int>600</int> </value>
                             </item>
                             <item>
                                 <key> <string>_mtime_func</string> </key>
@@ -319,6 +319,14 @@
                                   <none/>
                                 </value>
                             </item>
+                            <item>
+                                <key> <string>_stale_if_error_secs</string> </key>
+                                <value> <int>0</int> </value>
+                            </item>
+                            <item>
+                                <key> <string>_stale_while_revalidate_secs</string> </key>
+                                <value> <int>0</int> </value>
+                            </item>
                             <item>
                                 <key> <string>_vary</string> </key>
                                 <value> <string>Accept-Language, Cookie</string> </value>
@@ -433,7 +441,7 @@
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>python: getattr(object, \'getModificationDate\', object.modified)()</string> </value>
+            <value> <string>python: getattr(object, \'Base_getWebDocumentDrivenModificationDate\', object.modified)()</string> </value>
         </item>
       </dictionary>
     </pickle>
-- 
2.30.9