From 744dc3d587a38a89e295d80ae5935bc1adaae0b3 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Tue, 10 Sep 2019 09:33:16 +0200
Subject: [PATCH] Use script arguments rather than read directly request. Code
 format.

---
 .../ERP5Site_bootstrapScalabilityTest.py      | 22 ++++++++++++++-----
 .../ERP5Site_bootstrapScalabilityTest.xml     |  2 +-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.py b/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.py
index 29573318d0..6a244be92b 100644
--- a/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.py
+++ b/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.py
@@ -13,15 +13,19 @@ error_message = "No error."
 
 context.ERP5Site_setUpActivityTool()
 
-user_quantity = request.get('user_quantity')
-if user_quantity is None: return json.dumps({"status_code" : 1, "error_message": "Parameter 'user_quantity' is required.", "password" : None })
+if user_quantity is None: 
+  return json.dumps({"status_code" : 1, 
+                     "error_message": "Parameter 'user_quantity' is required.", 
+                     "password" : None })
+
 password = ''.join(random.choice(string.digits + string.letters) for i in xrange(10))
 
 # check erp5_scalability_test business template is present
 configurator = portal.business_configuration_module.default_standard_configuration
 if configurator == None or not configurator.contentValues(portal_type='Configuration Save'):
   error_message = "Could not find the scalability business configuration object. Be sure to have erp5_scalability_test business template installed."
-  return json.dumps({"status_code" : 1, "error_message": error_message })
+  return json.dumps({"status_code" : 1, 
+                     "error_message": error_message })
 
 # install configurator if not intalled
 if configurator.getSimulationState() == "draft":
@@ -33,7 +37,8 @@ if configurator.getSimulationState() == "draft":
     except Exception as e:
       status_code = 1
       error_message = "Error during installation: " + str(e)
-      return json.dumps({"status_code" : 1, "error_message": error_message })
+      return json.dumps({"status_code" : 1, 
+                         "error_message": error_message })
 
 # create users if installation is done
 try:
@@ -46,5 +51,10 @@ try:
 except Exception as e:
   status_code = 1
   error_message = "Error calling ERP5Site_createTestData script: " + str(e)
-  return json.dumps({"status_code" : 1, "error_message": error_message })
-return json.dumps({"status_code" : status_code, "error_message": error_message, "password" : password, "quantity" : user_quantity })
+  return json.dumps({"status_code" : 1, 
+                     "error_message": error_message })
+
+return json.dumps({"status_code" : status_code, 
+                   "error_message": error_message, 
+                   "password" : password, 
+                   "quantity" : user_quantity })
diff --git a/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.xml b/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.xml
index 27f059e3fb..99bbdcde68 100644
--- a/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.xml
+++ b/bt5/erp5_scalability_test/SkinTemplateItem/portal_skins/erp5_scalability_test/ERP5Site_bootstrapScalabilityTest.xml
@@ -50,7 +50,7 @@
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string></string> </value>
+            <value> <string>user_quantity=None</string> </value>
         </item>
         <item>
             <key> <string>guard</string> </key>
-- 
2.30.9