--- a/server/repository.py Wed Jul 27 14:03:09 2011 +0200
+++ b/server/repository.py Wed Jul 27 14:17:47 2011 +0200
@@ -927,14 +927,16 @@
nbclosed += 1
return nbclosed
- def internal_session(self, cnxprops=None):
- """return a dbapi like connection/cursor using internal user which
- have every rights on the repository. You'll *have to* commit/rollback
- or close (rollback implicitly) the session once the job's done, else
- you'll leak connections set up to the time where no one is
- available, causing irremediable freeze...
+ def internal_session(self, cnxprops=None, safe=False):
+ """return a dbapi like connection/cursor using internal user which have
+ every rights on the repository. The `safe` argument is a boolean flag
+ telling if integrity hooks should be activated or not.
+
+ *YOU HAVE TO* commit/rollback or close (rollback implicitly) the
+ session once the job's done, else you'll leak connections set up to the
+ time where no one is available, causing irremediable freeze...
"""
- session = InternalSession(self, cnxprops)
+ session = InternalSession(self, cnxprops, safe)
session.set_cnxset()
return session
--- a/server/session.py Wed Jul 27 14:03:09 2011 +0200
+++ b/server/session.py Wed Jul 27 14:17:47 2011 +0200
@@ -1276,12 +1276,13 @@
is_internal_session = True
running_dbapi_query = False
- def __init__(self, repo, cnxprops=None):
+ def __init__(self, repo, cnxprops=None, safe=False):
super(InternalSession, self).__init__(InternalManager(), repo, cnxprops,
_id='internal')
self.user._cw = self # XXX remove when "vreg = user._cw.vreg" hack in entity.py is gone
self.cnxtype = 'inmemory'
- self.disable_hook_categories('integrity')
+ if not safe:
+ self.disable_hook_categories('integrity')
@property
def cnxset(self):