[Erp5-report] r45813 luke - /erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed May 4 13:44:58 CEST 2011


Author: luke
Date: Wed May  4 13:44:58 2011
New Revision: 45813

URL: http://svn.erp5.org?rev=45813&view=rev
Log:
Support zope.conf configuration by using recent product_config attribute.
Do not use own section, as %import Products.TIDStorage is impossible, as code
is fired up during importing.

Modified:
    erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/README
    erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py

Modified: erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/README
URL: http://svn.erp5.org/erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/README?rev=45813&r1=45812&r2=45813&view=diff
==============================================================================
--- erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/README [utf8] (original)
+++ erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/README [utf8] Wed May  4 13:44:58 2011
@@ -46,6 +46,17 @@ Run bin/tidstorage.py with created confi
 it will connect to TIDStorage server, which will be shown in Zope and TIDStorage
 server logs.
 
+Zope 2.12+ configuration
+------------------------
+
+Put in zope.conf section:
+
+  <product-config TIDStorage>
+    backend-ip ip-of-tidstorage-server
+    backend-port port-of-tidstorage-server
+  </product-config>
+
+
 PYTHONPATH issues
 -----------------
 

Modified: erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py
URL: http://svn.erp5.org/erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py?rev=45813&r1=45812&r2=45813&view=diff
==============================================================================
--- erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py [utf8] (original)
+++ erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py [utf8] Wed May  4 13:44:58 2011
@@ -28,19 +28,47 @@
 
 from ExchangeProtocol import ExchangeProtocol
 from transaction._transaction import Transaction
-from zLOG import LOG, WARNING, INFO
+from zLOG import LOG, WARNING, INFO, ERROR
 import socket
 import thread
 import struct
 import sys
 
 GET_LAST_COMMITED_TID_METHOD_ID = 'getLastCommitedTID'
+from App.config import getConfiguration
+config = getConfiguration()
+# Note: TIDStorage is using simple <product-config tidstorage>
+# as patching is done during importing product, so it is impossible
+# to require %import Products.TIDStorage in zope.conf, as this code
+# will be fired during importing
 TID_STORAGE_ADDRESS = ('127.0.0.1', 9001)
+if getattr(config, 'product_config', None) is not None:
+  if not 'tidstorage' in config.product_config:
+    LOG('TIDStorage', ERROR, 'Missing section <product-config tidstorage> in '
+        'zope.conf')
+  else:
+    tidstorage_config = config.product_config['tidstorage']
+    if not 'backend-ip' in tidstorage_config or not 'backend-port' in \
+        tidstorage_config:
+      LOG('TIDStorage', ERROR, 'Please configure backend-ip and backend-port'
+          ' in <product-config tidstorage> section')
+    else:
+      try:
+        TID_STORAGE_ADDRESS = (tidstorage_config['backend-ip'],
+          int(tidstorage_config['backend-port']))
+      except ValueError:
+        LOG('TIDStorage', ERROR, 'backend-port shall be integer value, %r is '
+            'wrong' % tidstorage_config['backend-port'])
+else:
+  LOG('TIDStorage', WARNING, 'product_config is not supported, hardcoded '
+      'backend used.')
 
 tid_storage = None
 zope_identifier = None
 
-LOG('TIDStorage',INFO,'Monkey patching transaction._transaction.Transaction._commitResources')
+LOG('TIDStorage',INFO,'Monkey patching transaction._transaction.Transaction.'
+    '_commitResources, connected to %s' % ':'.join([str(q) for q in
+      TID_STORAGE_ADDRESS]))
 
 # Borrowed from CMFActivity.ActivityTool.getCurrentNode
 def getZopeId():



More information about the Erp5-report mailing list