server/repository.py
changeset 9127 aff75b69db92
parent 9113 af6efc15fc90
child 9402 2c48c091b6a2
equal deleted inserted replaced
9126:e0b63ea2c65b 9127:aff75b69db92
   951     def internal_session(self, cnxprops=None, safe=False):
   951     def internal_session(self, cnxprops=None, safe=False):
   952         """return a dbapi like connection/cursor using internal user which have
   952         """return a dbapi like connection/cursor using internal user which have
   953         every rights on the repository. The `safe` argument is a boolean flag
   953         every rights on the repository. The `safe` argument is a boolean flag
   954         telling if integrity hooks should be activated or not.
   954         telling if integrity hooks should be activated or not.
   955 
   955 
       
   956         /!\ the safe argument is False by default.
       
   957 
   956         *YOU HAVE TO* commit/rollback or close (rollback implicitly) the
   958         *YOU HAVE TO* commit/rollback or close (rollback implicitly) the
   957         session once the job's done, else you'll leak connections set up to the
   959         session once the job's done, else you'll leak connections set up to the
   958         time where no one is available, causing irremediable freeze...
   960         time where no one is available, causing irremediable freeze...
   959         """
   961         """
   960         session = InternalSession(self, cnxprops, safe)
   962         session = InternalSession(self, cnxprops, safe)
   961         session.set_cnxset()
   963         session.set_cnxset()
   962         return session
   964         return session
   963 
   965 
   964     @contextmanager
   966     @contextmanager
   965     def internal_cnx(self, safe=True):
   967     def internal_cnx(self):
   966         """return a Connection using internal user which have
   968         """return a Connection using internal user which have
   967         every rights on the repository. The `safe` argument is a boolean flag
   969         every rights on the repository. The `safe` argument is dropped. all
   968         telling if integrity hooks should be activated or not.
   970         hook are enabled by default.
   969 
   971 
   970         /!\ IN OPPOSITE OF THE OLDER INTERNAL_SESSION, INTERNAL CONNECTION ARE SAFE
   972         /!\ IN OPPOSITE OF THE OLDER INTERNAL_SESSION,
   971         /!\ BY DEFAULT.
   973         /!\ INTERNAL CONNECTION HAVE ALL HOOKS ENABLED.
   972 
   974 
   973         This is to be used a context manager.
   975         This is to be used a context manager.
   974         """
   976         """
   975         with InternalSession(self, safe) as session:
   977         with InternalSession(self) as session:
   976             with session.new_cnx() as cnx:
   978             with session.new_cnx() as cnx:
   977                 yield cnx
   979                 yield cnx
   978 
   980 
   979 
   981 
   980     def _get_session(self, sessionid, setcnxset=False, txid=None,
   982     def _get_session(self, sessionid, setcnxset=False, txid=None,