Here are some ideas about debugging.
Table of Contents
Wiki administration¶
Many information about debugging are merged into HowToDebugERP5.
Testing¶
Here I am going to post some ideas I have/had during the testing. It is an empty placeholder for now. If you are interested in this topic, please watch for updates and be ready
for discussion, you might very well have much better ideas than me.
Fast updates of the business templates
It can be a little bit tedious to manually rebuild the business templates, download them and then finally copy them to the bt5 folder. But it is quite easy to automate it. First
we need a script which will automatically rebuild the templates and export them:
1 template = context.portal_templates[template]
2 template.build()
3 # redirect, so that build and export are in two different transactions
4 return context.REQUEST.RESPONSE.redirect('%s/BusinessTemplate_export' % template.absolute_url())
5
6 # I (jerome) leave the above, because I'm not sure wget follow redirects by default.
7 # return template.BusinessTemplate_export()
I created a pythonscript in the portal_skin "custom" and called it download_template
To call it easily, we need to be able to call it. We use cookie based authentication in our erp5 project, so using a user from within erp5 is not easy. By creating a user in an
acl_users folder a level below we usually have a user which can be authenticated via http-auth, this can easily be done with wget. So we write a script to download all business
templates:
for i in module1 module2 module3 module5
do
wget --http-user=my_user --http-passwd=my_password http://127.0.0.1/erp5/download_template?template=myprefix_$i
mv download_template?template=myprefix_$i myprefix_$i.bt5
done
name this script as you wish, and put it in the correct folder. In our case we named it update_templates.sh and put it in /var/lib/zope/bt5/ourproject_bt5
Now you call the script and wait a bit, then you have the latest version of the business templates. Please beware, I used relate paths in my shell script. If you want to be
able to call the script from other directions, use absolute paths!
Access web interface from unit tests.
With ZopeTestCase, you can start a ZServer and use your web browser inside your test environment.
Enter this at pdb prompt:
1 (Pdb) import Testing.ZopeTestCase.utils
2 (Pdb) Testing.ZopeTestCase.utils.startZServer()
3 ('127.0.0.1', 55186) # ip address, port
In this example, a web server is started on port 55186. To acess your portal, you'll need to know your portal id (using ERP5TypeTestCase.getPortalId()). You can log as any user
created in the unit test.
I have this in my .pdbrc:
alias zserver import Testing.ZopeTestCase.utils; from AccessControl import getSecurityManager; import webbrowser;
webbrowser.open("http://%s:%s/%s/view?__ac_name=%s&__ac_password=%s" % ( Testing.ZopeTestCase.utils.startZServer() +
(self.getPortalId(), getSecurityManager().getUser(), getattr(getSecurityManager().getUser(), '__', '') )))
--
This can become a very specific howto. I would recommend to include this idea in ERP5 developer utils as a standard.
Related Articles¶