[Openerp-community] Reload openerp modules in running server

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Openerp-community] Reload openerp modules in running server

Nestor Diaz
Hello everyone, i am following instructions on how to develop an openerp
module from this:

http://www.ibcscorp.com/application-integration-customization/erp/openerp-2/openerp-custom-module-development-quick-start-guide/

nice and simple tutorial

I dediced to customize it and add another field to the model but in
order for openerp to recognize the changes made to the model i had to
restart the openerp-server.

Is there any way to reload a module without having to restart the
openerp server ? it seems that when i upgrade the model throuth the web
interface the xml files are

Could i implement a funcion inside the openerp module to reload himself
? something like the 'rollback importer'  
http://pyunit.sourceforge.net/notes/reloading.html ?

Is there any way to 'reload' the whole server instead of 'restart' the
server ? something that could be faster to deal with ? like zope debug
mode and refresh.txt files.

Thanks.

--
Nestor Diaz


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] Reload openerp modules in running server

Alexandre da Costa Leitão
Hi Nestor,

I think that’s not possible but, let me ask you something, here it doesn't take too much to restart the server? Is kind of fast and easy… you can create a script to do it or just click stop and start on eclipse… What hardware are you using? 

Regards,
ribbon ball  
Alexandre Leitão, Owner
OpenERP Ready Partner
Tel: (011) 3744-3170 | Mobile: (011) 8435-7021
www.infonetware.com.br
twitter facebook linkedin

On 03/04/12 16:32, "Nestor Diaz" <[hidden email]> wrote:

there any way to 'reload' the whole server instead of 'restart' the
server ? something that could be faster to deal with ? like zope debu

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] Reload openerp modules in running server

Nestor Diaz
I had made some tweaks on the __init__.py in order to fire up a new
thread that watch for a file, in case it find it it will reload the
python module

this is the code:

import notebook
import os
from threading import Thread
import time
import sys, traceback

import logging

_logger = logging.getLogger('notebook')

filename="/usr/local/openerp/6.1/devel/openerp/addons/notebook/refresh.txt"

# Define thread behaivour
class myreload(Thread):
def __init__ (self):
Thread.__init__(self)
def run(self):
while 1:
if os.path.exists(filename):
_logger.critical('reload')
os.remove(filename)
try:
reload(notebook)
except Exception:
_logger.critical('shit happens')
exc_type, exc_value, exc_traceback = sys.exc_info()
_logger.critical(repr(traceback.extract_tb(exc_traceback)))
time.sleep(1)

# Create thread
_myreload = myreload()
# Start thread
_myreload.start()

and when i create a refresh.txt file i got:

2012-04-03 23:13:08,829 26646 CRITICAL ? notebook: reload

and when shit happens:

2012-04-03 23:13:16,839 26646 CRITICAL ? notebook: reload
2012-04-03 23:13:16,840 26646 CRITICAL ? notebook: shit happens
2012-04-03 23:13:16,840 26646 CRITICAL ? notebook:
[('/usr/local/openerp/6.1/devel/openerp/addons/notebook/__init__.py',
23, 'run', 'reload(notebook)'),
('/usr/local/openerp/6.1/devel/openerp/addons/notebook/notebook.py', 4,
'<module>', 'arst')]

i fixed the file and then it reloads again:

2012-04-03 23:13:55,885 26646 CRITICAL ? notebook: reload

off coure it only works for reloading python classes since .xml files
are reloaded when i upgrade a module., so i just put the refresh.txt and
have another tab with the modules page and reload !

Regarding your question: i have a quad core i5 3.1 Ghz 64 bits with 16
GB ram, enought to play more than fine with openerp, the problem is not
restarting the server , the problem is waiting a half minute for the
gears to finish moving on the chrome browser screen every time i restart
the server and go to the modules section.

Anyway other python based systems like zope and django supports
reloading for development environment, why openerp don't ?

Slds.

--
Nestor

On 04/03/2012 04:12 PM, Alexandre da Costa Leitão wrote:

> Hi Nestor,
>
> I think that’s not possible but, let me ask you something, here it
> doesn't take too much to restart the server? Is kind of fast and easy…
> you can create a script to do it or just click stop and start on
> eclipse… What hardware are you using?
>
> Regards,
> ribbon ball
> *Alexandre Leitão, Owner
> **OpenERP Ready Partner*
> Tel: (011) 3744-3170 | Mobile: (011) 8435-7021
> www.infonetware.com.br <http://www.infonetware.com.br/>
> twitter facebook linkedin
>
>
> On 03/04/12 16:32, "Nestor Diaz" <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     there any way to 'reload' the whole server instead of 'restart' the
>     server ? something that could be faster to deal with ? like zope debu
>


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|

Re: [Openerp-community] Reload openerp modules in running server

Nestor Diaz
Sorry, the code wasn't well formatted, the code is here:

http://pastebin.com/TvuFKyKu

--
Nestor

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp