[session] make security_enabled API private
The doc already says "internal API". The old entry point is now officially
deprecated and the context manager have been made private.
--- a/server/session.py Fri Mar 29 12:47:04 2013 +0100
+++ b/server/session.py Fri Mar 29 18:57:13 2013 +0100
@@ -145,8 +145,11 @@
finally:
self.tx.hooks_mode = self.oldmode
+@deprecated('[3.17] use <object>.security_enabled instead')
+def security_enabled(obj, *args, **kwargs):
+ return obj.security_enabled(*args, **kwargs)
-class security_enabled(object):
+class _security_enabled(object):
"""context manager to control security w/ session.execute,
By default security is disabled on queries executed on the repository
@@ -855,7 +858,7 @@
'''
edited_entities = {}
relations_dict = {}
- with security_enabled(self, False, False):
+ with self.security_enabled(False, False):
for rtype, eids in relations:
if self.vreg.schema[rtype].inlined:
for fromeid, toeid in eids:
@@ -884,7 +887,7 @@
You may use this in hooks when you know both eids of the relation you
want to delete.
"""
- with security_enabled(self, False, False):
+ with self.security_enabled(False, False):
if self.vreg.schema[rtype].inlined:
entity = self.entity_from_eid(fromeid)
entity.cw_attr_cache[rtype] = None
@@ -989,7 +992,7 @@
def security_enabled(self, read=None, write=None):
- return security_enabled(self, read=read, write=write)
+ return _security_enabled(self, read=read, write=write)
read_security = tx_attr('read_security', writable=True)
write_security = tx_attr('write_security', writable=True)
@@ -1212,7 +1215,7 @@
debug = server.DEBUG & server.DBG_OPS
try:
# by default, operations are executed with security turned off
- with security_enabled(self, False, False):
+ with self.security_enabled(False, False):
processed = []
self.commit_state = 'precommit'
if debug:
@@ -1291,7 +1294,7 @@
return
try:
# by default, operations are executed with security turned off
- with security_enabled(self, False, False):
+ with self.security_enabled(False, False):
while self.pending_operations:
try:
operation = self.pending_operations.pop(0)