907 session.set_cnxset() |
907 session.set_cnxset() |
908 return session |
908 return session |
909 |
909 |
910 @contextmanager |
910 @contextmanager |
911 def internal_cnx(self): |
911 def internal_cnx(self): |
912 """return a Connection using internal user which have |
912 """Context manager returning a Connection using internal user which have |
913 every rights on the repository. The `safe` argument is dropped. all |
913 every access rights on the repository. |
914 hook are enabled by default. |
914 |
915 |
915 Beware that unlike the older :meth:`internal_session`, internal |
916 /!\ IN OPPOSITE OF THE OLDER INTERNAL_SESSION, |
916 connections have all hooks beside security enabled. |
917 /!\ INTERNAL CONNECTION HAVE ALL HOOKS ENABLED. |
|
918 |
|
919 This is to be used a context manager. |
|
920 """ |
917 """ |
921 with InternalSession(self) as session: |
918 with InternalSession(self) as session: |
922 with session.new_cnx() as cnx: |
919 with session.new_cnx() as cnx: |
923 # equivalent to cnx.security_enabled(False, False) because |
920 with cnx.security_enabled(read=False, write=False): |
924 # InternalSession gives full read access |
|
925 with cnx.allow_all_hooks_but('security'): |
|
926 with cnx.ensure_cnx_set: |
921 with cnx.ensure_cnx_set: |
927 yield cnx |
922 yield cnx |
928 |
|
929 |
923 |
930 def _get_session(self, sessionid, setcnxset=False, txid=None, |
924 def _get_session(self, sessionid, setcnxset=False, txid=None, |
931 checkshuttingdown=True): |
925 checkshuttingdown=True): |
932 """return the session associated with the given session identifier""" |
926 """return the session associated with the given session identifier""" |
933 if checkshuttingdown and self.shutting_down: |
927 if checkshuttingdown and self.shutting_down: |