Example #1
0
    def open(self, db=None, with_demo=False):
        """Load the database

        Loading an empty database in Odoo has the side effect of installing
        the ``base`` module. Whether to loading demo data or not has therefore
        to be decided right away.

        :param db: database name. If not specified, the same cascading of
                   defaults as Odoo mainstream will be applied:
                   configuration file, psycopg2/lipq defaults.
        :param with_demo: controls the loading of demo data for all
                          module installations triggered by this call to
                          :meth:`open` and further uses of :meth:`load_modules`
                          on this :class:`Session` instance:

                          * if ``True``, demo data will uniformly be loaded
                          * if ``False``, no demo data will be loaded
                          * if ``None``, demo data will be loaded according to
                            the value of ``without_demo`` in configuration

                          In all cases, the behaviour will stay consistent
                          until the next call of ``open()``, but the
                          implementation does not protect against any race
                          conditions in Odoo internals.
        """
        if db is None:
            db = config['db_name']
        if not db:
            db = ''  # expected value expected by Odoo to start defaulting.
        else:
            config['dbfilter'] = '$%s^' % db

        cnx = openerp.sql_db.db_connect(db)
        cr = cnx.cursor()
        self.is_initialization = not(openerp.modules.db.is_initialized(cr))
        cr.close()

        startup.check_root_user()
        if not os.environ.get('ENABLE_POSTGRES_USER'):
            startup.check_postgres_user()
        openerp.netsvc.init_logger()

        saved_without_demo = config['without_demo']
        if with_demo is None:
            with_demo = config['without_demo']

        config['without_demo'] = not with_demo
        self.with_demo = with_demo

        self._registry = openerp.modules.registry.RegistryManager.get(
            db, update_module=False)
        config['without_demo'] = saved_without_demo
        self.init_cursor()
        self.uid = SUPERUSER_ID
        self.init_environments()
        self.context = self.registry('res.users').context_get(
            self.cr, self.uid)
        if hasattr(openerp, 'api'):
            self.env.context = self.context
Example #2
0
    def open(self, db=None, with_demo=False):
        """Load the database

        Loading an empty database in Odoo has the side effect of installing
        the ``base`` module. Whether to loading demo data or not has therefore
        to be decided right away.

        :param db: database name. If not specified, the same cascading of
                   defaults as Odoo mainstream will be applied:
                   configuration file, psycopg2/lipq defaults.
        :param with_demo: controls the loading of demo data for all
                          module installations triggered by this call to
                          :meth:`open` and further uses of :meth:`load_modules`
                          on this :class:`Session` instance:

                          * if ``True``, demo data will uniformly be loaded
                          * if ``False``, no demo data will be loaded
                          * if ``None``, demo data will be loaded according to
                            the value of ``without_demo`` in configuration

                          In all cases, the behaviour will stay consistent
                          until the next call of ``open()``, but the
                          implementation does not protect against any race
                          conditions in Odoo internals.
        """
        if db is None:
            db = config['db_name']
        if not db:
            db = ''  # expected value expected by Odoo to start defaulting.

        cnx = openerp.sql_db.db_connect(db)
        cr = cnx.cursor()
        self.is_initialization = not(openerp.modules.db.is_initialized(cr))
        cr.close()

        startup.check_root_user()
        startup.check_postgres_user()
        openerp.netsvc.init_logger()

        saved_without_demo = config['without_demo']
        if with_demo is None:
            with_demo = config['without_demo']

        config['without_demo'] = not with_demo
        self.with_demo = with_demo

        self._registry = openerp.modules.registry.RegistryManager.get(
            db, update_module=False)
        config['without_demo'] = saved_without_demo
        self.init_cursor()
        self.uid = SUPERUSER_ID
        self.init_environments()
        self.context = self.registry('res.users').context_get(
            self.cr, self.uid)
        if hasattr(openerp, 'api'):
            self.env = openerp.api.Environment(self.cr, self.uid, self.context)
Example #3
0
                self.setproctitle(db_name)
                db = openerp.sql_db.db_connect(db_name)
                threading.current_thread().dbname = db_name
                with closing(db.cursor()) as cr:
                    self._work_database(cr)
            else:
                self.db_index = 0

    def sleep(self):
        # Really sleep once all the databases have been processed.
        if self.db_index == 0:
            interval = 15 + self.pid % self.multi.population  # chorus effect
            time.sleep(interval)

    def start(self):
        workers.Worker.start(self)


if __name__ == "__main__":
    args = sys.argv[1:]
    servercli.check_root_user()
    config.parse_config(args)

    servercli.check_postgres_user()
    openerp.netsvc.init_logger()
    servercli.report_configuration()

    openerp.multi_process = True
    openerp.worker_connector = True
    Multicornnector(openerp.service.wsgi_server.application).run([], False)
Example #4
0
logging.config.dictConfig(config['logging'])

import openerp

openerp.conf.server_wide_modules = []

conf = openerp.tools.config
conf['addons_path'] = os.path.join(current_dir, 'openerp', 'addons')
conf['static_http_document_root'] = current_dir

conf['db_host'] = config['db']['host']
conf['db_user'] = config['db']['user']
conf['db_port'] = config['db']['port']
conf['db_password'] = config['db']['password']
conf['admin_passwd'] = config['admin']['password']
conf['log_level'] = config['log_level']

from openerp.cli import server
server.check_root_user()
server.check_postgres_user()
server.report_configuration()
server.setup_pid_file()
server.preload_registry(config['company_db'])

openerp.modules.module.initialize_sys_path()
openerp.modules.loading.open_openerp_namespace()

logger = logging.getLogger()
logger.debug("Starting workers")
openerp.service.cron.cron_runner(0)
Example #5
0
                self.setproctitle(db_name)
                db = openerp.sql_db.db_connect(db_name)
                threading.current_thread().dbname = db_name
                with closing(db.cursor()) as cr:
                    self._work_database(cr)
            else:
                self.db_index = 0

    def sleep(self):
        # Really sleep once all the databases have been processed.
        if self.db_index == 0:
            interval = 15 + self.pid % self.multi.population  # chorus effect
            time.sleep(interval)

    def start(self):
        workers.Worker.start(self)


if __name__ == "__main__":
    args = sys.argv[1:]
    servercli.check_root_user()
    config.parse_config(args)

    servercli.check_postgres_user()
    openerp.netsvc.init_logger()
    servercli.report_configuration()

    openerp.multi_process = True
    openerp.worker_connector = True
    Multicornnector(openerp.service.wsgi_server.application).run([], False)