import openerp.sql_db
import openerp.osv.orm
-import openerp.cron
import openerp.tools
import openerp.modules.db
import openerp.tools.config
self._init = True
self._init_parent = {}
self._assertion_report = assertion_report.assertion_report()
+ self.fields_by_model = None
# modules fully loaded (maintained during init phase by `loading` module)
self._init_modules = set()
self.db_name = db_name
self.db = openerp.sql_db.db_connect(db_name)
+ # In monoprocess cron jobs flag (pooljobs)
+ self.cron = False
+
# Inter-process signaling (used only when openerp.multi_process is True):
# The `base_registry_signaling` sequence indicates the whole registry
# must be reloaded.
and registers them in the registry.
"""
-
- res = []
-
+ models_to_load = [] # need to preserve loading order
# Instantiate registered classes (via the MetaModel automatic discovery
# or via explicit constructor call), and add them to the pool.
for cls in openerp.osv.orm.MetaModel.module_to_models.get(module.name, []):
- res.append(cls.create_instance(self, cr))
-
- return res
+ # models register themselves in self.models
+ model = cls.create_instance(self, cr)
+ if model._name not in models_to_load:
+ # avoid double-loading models whose declaration is split
+ models_to_load.append(model._name)
+ return [self.models[m] for m in models_to_load]
def schedule_cron_jobs(self):
""" Make the cron thread care about this registry/database jobs.
monitor the ir.cron model for future jobs. See openerp.cron for
details.
"""
- openerp.cron.schedule_wakeup(openerp.cron.WAKE_UP_NOW, self.db.dbname)
+ self.cron = True
def clear_caches(self):
""" Clear the caches
@classmethod
def delete(cls, db_name):
- """Delete the registry linked to a given database.
-
- This also cleans the associated caches. For good measure this also
- cancels the associated cron job. But please note that the cron job can
- be running and take some time before ending, and that you should not
- remove a registry if it can still be used by some thread. So it might
- be necessary to call yourself openerp.cron.Agent.cancel(db_name) and
- and join (i.e. wait for) the thread.
- """
+ """Delete the registry linked to a given database. """
with cls.registries_lock:
if db_name in cls.registries:
cls.registries[db_name].clear_caches()
del cls.registries[db_name]
- openerp.cron.cancel(db_name)
@classmethod
def delete_all(cls):