[Erp5-report] r43537 rafael - /erp5/trunk/utils/rpmgen/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Feb 21 22:23:43 CET 2011


Author: rafael
Date: Mon Feb 21 22:23:43 2011
New Revision: 43537

URL: http://svn.erp5.org?rev=43537&view=rev
Log:
Dirty way to instantiate a ERP5 Site, this is temporaty required due lack of this feature on buildout recipes.

Added:
    erp5/trunk/utils/rpmgen/build-demo-instance.py
    erp5/trunk/utils/rpmgen/build-demo-instance.sh

Added: erp5/trunk/utils/rpmgen/build-demo-instance.py
URL: http://svn.erp5.org/erp5/trunk/utils/rpmgen/build-demo-instance.py?rev=43537&view=auto
==============================================================================
--- erp5/trunk/utils/rpmgen/build-demo-instance.py (added)
+++ erp5/trunk/utils/rpmgen/build-demo-instance.py [utf8] Mon Feb 21 22:23:43 2011
@@ -0,0 +1,70 @@
+import transaction
+
+def tic(portal):
+  """
+  Start all messages
+  """
+  portal_activities = portal.portal_activities
+  count = 1000
+  while len(portal_activities.getMessageList()) > 0:
+    portal_activities.process_timer(None, None)
+    # This prevents an infinite loop.
+    count -= 1
+    if count == 0:
+      # Get the last error message from error_log.
+      error_message = ''
+      error_log = portal.error_log._getLog()
+      if len(error_log):
+        last_log = error_log[-1]
+        error_message = '\nLast error message:\n%s\n%s\n%s\n' % (
+          last_log['type'],
+          last_log['value'],
+          last_log['tb_text'],
+          )
+      raise RuntimeError,\
+        'tic is looping forever. These messages are pending: %r %s' % (
+      [('/'.join(m.object_path), m.method_id, m.processing_node, m.priority)
+       for m in portal_activities.getMessageList()],
+      error_message
+      )
+    # This give some time between messages
+    if count % 10 == 0:
+      from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
+      portal_activities.timeShift(3 * VALIDATION_ERROR_DELAY)
+
+from Testing.makerequest import makerequest
+user = app.acl_users.getUserById('zope')
+user = user.__of__(app.acl_users)
+
+from AccessControl.SecurityManagement import newSecurityManager
+newSecurityManager(None, user)
+
+transaction.commit()
+
+# change user
+context = makerequest(app)
+mysql_connection_string = 'development_site at 127.0.0.1:10002 development_user development_password'
+# make a portal
+factory = context.manage_addProduct['ERP5']
+factory.manage_addERP5Site('erp5',
+                           erp5_catalog_storage='erp5_mysql_innodb_catalog',
+                           erp5_sql_connection_string=mysql_connection_string,
+                           cmf_activity_sql_connection_string=mysql_connection_string)
+
+portal = getattr(context, 'erp5')
+tic(portal)
+
+template = portal.portal_templates.download("https://svn.erp5.org/repos/public/erp5/trunk/bt5/erp5_demo_smb")
+#template = portal.portal_templates.download('http://www.erp5.org/dists/snapshot/bt5/erp5_demo_smb.bt5')
+template.install()
+transaction.commit()
+
+context = makerequest(context)
+portal = getattr(context, 'erp5')
+portal.portal_alarms.setup_demo_smb.Alarm_setupDemoConfiguration()
+
+transaction.commit()
+
+context = makerequest(context)
+portal = getattr(context, 'erp5')
+tic(portal)

Added: erp5/trunk/utils/rpmgen/build-demo-instance.sh
URL: http://svn.erp5.org/erp5/trunk/utils/rpmgen/build-demo-instance.sh?rev=43537&view=auto
==============================================================================
--- erp5/trunk/utils/rpmgen/build-demo-instance.sh (added)
+++ erp5/trunk/utils/rpmgen/build-demo-instance.sh [utf8] Mon Feb 21 22:23:43 2011
@@ -0,0 +1,9 @@
+/var/lib/erp5/smb001/var/bin/supervisord
+
+/var/lib/erp5/smb001/var/bin/supervisorctl stop development-site
+sed -i "s/enable-product-installation off/enable-product-installation on/g" /var/lib/erp5/smb001/parts/development-site/etc/zope.conf
+
+/var/lib/erp5/smb001/bin/development-site run build-demo-instance.py
+
+/var/lib/erp5/smb001/var/bin/supervisorctl shutdown
+sed -i "s/enable-product-installation on/enable-product-installation off/g" /var/lib/erp5/smb001/parts/development-site/etc/zope.conf



More information about the Erp5-report mailing list