Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
erp5
Commits
5c187338
Commit
5c187338
authored
Sep 06, 2011
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add example script to create many ERP5 users at once
parent
0f6c312f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
erp5/util/testbrowser/examples/createERP5User.py
erp5/util/testbrowser/examples/createERP5User.py
+57
-0
No files found.
erp5/util/testbrowser/examples/createERP5User.py
0 → 100755
View file @
5c187338
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Script to automatically create a given number of Zope users, which can be
# useful for performance/scalability testing. This script is really basic as,
# for example, it does not check if the user already exists (Zope will just
# state that the user already exists but do not raise an HTTP error).
#
# TODO: There must be a better way than the code below to do that though...
import
sys
from
erp5.util.testbrowser.browser
import
Browser
try
:
url
,
site_id
,
username
,
password
,
user_nbr
,
new_username_prefix
,
\
new_password
=
sys
.
argv
[
1
:]
user_nbr
=
int
(
user_nbr
)
except
ValueError
:
print
>>
sys
.
stderr
,
"ERROR: Missing arguments: %s URL SITE_ID USERNAME "
\
"PASSWORD NUMBER_OF_USERS NEW_USERNAME_PREFIX NEW_USERS_PASSWORD"
%
\
sys
.
argv
[
0
]
sys
.
exit
(
1
)
# Create a browser instance
browser
=
Browser
(
url
,
site_id
,
username
=
username
,
password
=
password
)
erp5_role_tuple
=
(
'Assignee'
,
'Assignor'
,
'Associate'
,
'Auditor'
,
'Author'
,
'Manager'
,
'Member'
,
'Owner'
,
'Reviewer'
)
post_data_format
=
"submit=Add&roles:list=Manager&roles:list=Owner&name="
\
"%(username)s&password=%(password)s&confirm=%(password)s"
for
index
in
range
(
user_nbr
):
new_username
=
"%s%d"
%
(
new_username_prefix
,
index
)
browser
.
open
(
'/acl_users/manage_users'
)
browser
.
post
(
'%s/acl_users/manage_users'
%
url
,
post_data_format
%
{
'username'
:
new_username
,
'password'
:
new_password
})
browser
.
open
(
'manage_listLocalRoles'
)
form
=
browser
.
getForm
(
action
=
'manage_setLocalRoles'
)
form
.
getControl
(
name
=
'userid'
).
value
=
new_username
form
.
getControl
(
name
=
'roles:list'
).
value
=
erp5_role_tuple
form
.
submit
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment