[server] move security/integrity hook management away from InternalSession.__init__
and to Repository.internal_{session,cnx} instead. Lets internal_cnx avoid
deprecation warnings.
--- a/server/repository.py Thu Apr 03 17:25:53 2014 +0200
+++ b/server/repository.py Fri Apr 04 10:46:53 2014 +0200
@@ -925,7 +925,11 @@
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, safe)
+ session = InternalSession(self, cnxprops)
+ if not safe:
+ session.disable_hook_categories('integrity')
+ session.disable_hook_categories('security')
+ session._cnx.ctx_count += 1
session.set_cnxset()
return session
@@ -942,7 +946,8 @@
"""
with InternalSession(self) as session:
with session.new_cnx() as cnx:
- yield cnx
+ with cnx.allow_all_hooks_but('security'):
+ yield cnx
def _get_session(self, sessionid, setcnxset=False, txid=None,
--- a/server/session.py Thu Apr 03 17:25:53 2014 +0200
+++ b/server/session.py Fri Apr 04 10:46:53 2014 +0200
@@ -1748,10 +1748,6 @@
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
- if not safe:
- self.disable_hook_categories('integrity')
- self.disable_hook_categories('security')
- self._cnx.ctx_count += 1
def __enter__(self):
return self