Tuesday, December 6, 2011

Setting up the development environment

With the server files available through a file sharing service, you just need to edit them with your favourite editor. A good option on Windows is Notepad++.

For Pyhton development it's advisable to have a good IDE, and there are several options availableSpyder can be a good option. It provides features like code tree outline, selected text highlighting, automatic code analysis function, and a step-by-step debugger (with winpdb).

Changes to module's Python code require a server restart in order to reload it to memory. You will find  running the server manually from the terminal to be more flexible and practical when developing modules.
To do this, stop the openerp-server service and manually start an instance, as in the example below. You can then follow the log in the web-console's window:

root@openerp ~# service openerp-server stop                                                   
Stopping openerp-server: openerp-server.                                                     
root@openerp ~# su openerp                                                                   
openerp@openerp:/root$ cd /opt/openerp/ 
openerp@openerp:~$ server/bin/openerp-server.py --config=openerp-server.conf --log-level=debug


[2011-12-06 09:34:45,523][?] INFO:server:OpenERP version - 6.0.3                              
[2011-12-06 09:34:45,523][?] INFO:server:addons_path - /opt/openerp/server/bin/addons        
[2011-12-06 09:34:45,523][?] INFO:server:database hostname - localhost                       
[2011-12-06 09:34:45,523][?] INFO:server:database port - 5432                                
[2011-12-06 09:34:45,523][?] INFO:server:database user - openerp                             
[2011-12-06 09:34:45,523][?] INFO:server:initialising distributed objects services           
[2011-12-06 09:34:45,665][?] DEBUG:psycopg2:installed. Logging using Python logging module   
[2011-12-06 09:34:45,666][?] DEBUG:web-services:Registered an exported service: db           
[2011-12-06 09:34:45,666][?] DEBUG:web-services:Registered an exported service: common        
[2011-12-06 09:34:45,667][?] DEBUG:web-services:Registered an exported service: object       
[2011-12-06 09:34:45,667][?] DEBUG:web-services:Registered an exported service: wizard       
[2011-12-06 09:34:45,667][?] DEBUG:web-services:Registered an exported service: report       
[2011-12-06 09:34:45,684][?] INFO:web-services:starting HTTP service at 0.0.0.0 port 8069    
[2011-12-06 09:34:45,686][?] INFO:web-services:starting HTTPS service at 0.0.0.0 port 8071   
[2011-12-06 09:34:45,686][?] INFO:web-services:Registered XML-RPC over HTTP                  
[2011-12-06 09:34:45,687][?] INFO:web-services:starting NET-RPC service at 0.0.0.0 port 8070 
[2011-12-06 09:34:45,687][?] INFO:server:Starting 3 services                                 
[2011-12-06 09:34:45,688][?] INFO:server:OpenERP server is running, waiting for connections...

If the server fails to start, it may be that there is still an instance running. If that's the case you can solve it by killing the process. List the OpenERP running processes, find the process ID and kill it: On the terminal type:
ps aux|grep openerp-server
sudo kill -9 [PID]



Running openerp-server with the --help option will present you all the options available.
In certain cases you may want to set the --log-level to debug_rpc or to debug_answer to get more detail on the client-server interactions.
And adding the --debug option allows you to enter Python's debugger (pdb) when an exception is raised.
To restart the server, press CTRL+C and execute the start command again. Note that there is no need exit and re-login the client sessions, because they are stateless.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete