# Useful only in a multi-process context.
self._any_cache_cleared = False
- cr = self.db.cursor()
+ cr = self.get_cursor()
has_unaccent = openerp.modules.db.has_unaccent(cr)
if openerp.tools.config['unaccent'] and not has_unaccent:
_logger.warning("The option --unaccent was given but no unaccent() function was found in database.")
r, c)
return r, c
+ def get_cursor(self):
+ """ Return a new cursor for the database. """
+ return self.db.cursor()
+
@contextmanager
def cursor(self, auto_commit=True):
- cr = self.db.cursor()
+ """ Manage a new cursor; commit, rollback and closing are automatic. """
+ cr = self.get_cursor()
try:
yield cr
if auto_commit:
# Yeah, crazy.
registry = cls.registries[db_name]
- cr = registry.db.cursor()
+ cr = registry.get_cursor()
try:
registry.do_parent_store(cr)
cr.commit()
changed = False
if openerp.multi_process and db_name in cls.registries:
registry = cls.get(db_name)
- cr = registry.db.cursor()
+ cr = registry.get_cursor()
try:
cr.execute("""
SELECT base_registry_signaling.last_value,
registry = cls.get(db_name)
if registry.any_cache_cleared():
_logger.info("At least one model cache has been cleared, signaling through the database.")
- cr = registry.db.cursor()
+ cr = registry.get_cursor()
r = 1
try:
cr.execute("select nextval('base_cache_signaling')")
if openerp.multi_process and db_name in cls.registries:
_logger.info("Registry changed, signaling through the database")
registry = cls.get(db_name)
- cr = registry.db.cursor()
+ cr = registry.get_cursor()
r = 1
try:
cr.execute("select nextval('base_registry_signaling')")