[Erp5-report] r38134 aurel - in /erp5/trunk/products/ERP5Type: Tool/ dtml/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Sep 3 11:04:15 CEST 2010


Author: aurel
Date: Fri Sep  3 11:04:08 2010
New Revision: 38134

URL: http://svn.erp5.org?rev=38134&view=rev
Log:
add a tab which allows to reload a Product on a running instance

Added:
    erp5/trunk/products/ERP5Type/dtml/viewProductReload.dtml
Modified:
    erp5/trunk/products/ERP5Type/Tool/ClassTool.py

Modified: erp5/trunk/products/ERP5Type/Tool/ClassTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/ClassTool.py?rev=38134&r1=38133&r2=38134&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/ClassTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/ClassTool.py [utf8] Fri Sep  3 11:04:08 2010
@@ -43,6 +43,7 @@ from Acquisition import Implicit
 from AccessControl import ClassSecurityInfo
 from Products.ERP5Type.Globals import InitializeClass, DTMLFile
 from App.config import getConfiguration
+from App import RefreshFuncs
 from Shared.DC.ZRDB.TM import TM
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
@@ -328,6 +329,9 @@ if allowClassTool():
                           ,{ 'label'      : 'Tests'
                           , 'action'     : 'manage_viewTestList'
                           }
+                          ,{ 'label'      : 'Reload Product'
+                          , 'action'     : 'manage_viewProductReload'
+                          }
                           ,{ 'label'      : 'Product Generation'
                           , 'action'     : 'manage_viewProductGeneration'
                           }
@@ -374,6 +378,9 @@ if allowClassTool():
       security.declareProtected( Permissions.ManagePortal, 'manage_viewProductGeneration' )
       manage_viewProductGeneration = DTMLFile( 'viewProductGeneration', _dtmldir )
 
+      security.declareProtected( Permissions.ManagePortal, 'manage_viewProductReload' )
+      manage_viewProductReload = DTMLFile( 'viewProductReload', _dtmldir )
+
       def _clearCache(self):
         """
           Clears the cache of all databases
@@ -1192,6 +1199,26 @@ def initialize( context ):
         path = os.path.join(getConfiguration().instancehome, 'tests')
         return runLiveTest(test_list, run_only=run_only, debug=debug, path=path)
 
+      def getProductList(self):
+        """ List all products """
+        return self.Control_Panel.Products.objectIds()
+
+      def reloadProduct(self, product_id, REQUEST=None):
+        """ Reload a given product """
+        product = self.Control_Panel.Products[product_id]
+        if product._readRefreshTxt() is None:
+            raise Unauthorized, 'refresh.txt not found'
+        message = None
+        if RefreshFuncs.performFullRefresh(product._p_jar, product.id):
+            from ZODB import Connection
+            Connection.resetCaches() # Clears cache in future connections.
+            message = 'Product refreshed.'
+        else:
+            message = 'An exception occurred. Check your log'
+
+        if REQUEST is not None:
+          REQUEST.RESPONSE.redirect('%s/manage_viewProductReload?manage_tabs_message=%s' % (self.absolute_url(), message))
+
 else:
 
   class ClassTool(BaseTool, ClassToolMixIn):

Added: erp5/trunk/products/ERP5Type/dtml/viewProductReload.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/dtml/viewProductReload.dtml?rev=38134&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/dtml/viewProductReload.dtml (added)
+++ erp5/trunk/products/ERP5Type/dtml/viewProductReload.dtml [utf8] Fri Sep  3 11:04:08 2010
@@ -0,0 +1,32 @@
+<dtml-var manage_page_header>
+<dtml-var manage_tabs>
+
+<div class="std-text"><p><strong>Reload Products</strong></p></div>
+
+<table width="100%">
+  <tr class="list-header">
+    <th>
+      Product
+    </th>
+    <th>
+      Action
+    </th>
+  <dtml-in getProductList>
+  <dtml-if sequence-odd>
+  <tr class="row-normal">
+  <dtml-else>
+  <tr class="row-hilite">
+  </dtml-if>
+    <td>
+      <div class="list-item"><dtml-var sequence-item></div>
+    </td>   
+    <td>
+      <div class="list-item"><a href="reloadProduct?product_id=<dtml-var sequence-item>">reload</a></div>
+    </td>   
+  </tr>    
+  </dtml-in>
+</table>
+
+<hr/>
+
+<dtml-var manage_page_footer>




More information about the Erp5-report mailing list