server/session.py
changeset 8781 f1a5792dd8a3
parent 8780 d3e49fc74e79
child 8782 ee675f0a9612
equal deleted inserted replaced
8780:d3e49fc74e79 8781:f1a5792dd8a3
   650                 self.set_write_security(write)
   650                 self.set_write_security(write)
   651 
   651 
   652     @property
   652     @property
   653     def read_security(self):
   653     def read_security(self):
   654         """return a boolean telling if read security is activated or not"""
   654         """return a boolean telling if read security is activated or not"""
   655         tx = self._tx
   655         return  self._tx.read_security
   656         if tx is None:
       
   657             return DEFAULT_SECURITY
       
   658         return tx.read_security
       
   659 
   656 
   660     def set_read_security(self, activated):
   657     def set_read_security(self, activated):
   661         """[de]activate read security, returning the previous value set for
   658         """[de]activate read security, returning the previous value set for
   662         later restoration.
   659         later restoration.
   663 
   660 
   664         you should usually use the `security_enabled` context manager instead
   661         you should usually use the `security_enabled` context manager instead
   665         of this to change security settings.
   662         of this to change security settings.
   666         """
   663         """
   667         tx = self._tx
   664         tx = self._tx
   668         if tx is None:
       
   669             return DEFAULT_SECURITY
       
   670         oldmode = tx.read_security
   665         oldmode = tx.read_security
   671         tx.read_security = activated
   666         tx.read_security = activated
   672         # dbapi_query used to detect hooks triggered by a 'dbapi' query (eg not
   667         # dbapi_query used to detect hooks triggered by a 'dbapi' query (eg not
   673         # issued on the session). This is tricky since we the execution model of
   668         # issued on the session). This is tricky since we the execution model of
   674         # a (write) user query is:
   669         # a (write) user query is:
   690         return oldmode
   685         return oldmode
   691 
   686 
   692     @property
   687     @property
   693     def write_security(self):
   688     def write_security(self):
   694         """return a boolean telling if write security is activated or not"""
   689         """return a boolean telling if write security is activated or not"""
   695         tx = self._tx
   690         return self._tx.write_security
   696         if tx is None:
       
   697             return DEFAULT_SECURITY
       
   698         return tx.write_security
       
   699 
   691 
   700     def set_write_security(self, activated):
   692     def set_write_security(self, activated):
   701         """[de]activate write security, returning the previous value set for
   693         """[de]activate write security, returning the previous value set for
   702         later restoration.
   694         later restoration.
   703 
   695 
   704         you should usually use the `security_enabled` context manager instead
   696         you should usually use the `security_enabled` context manager instead
   705         of this to change security settings.
   697         of this to change security settings.
   706         """
   698         """
   707         tx = self._tx
   699         tx = self._tx
   708         if tx is None:
       
   709             return DEFAULT_SECURITY
       
   710         oldmode = tx.write_security
   700         oldmode = tx.write_security
   711         tx.write_security = activated
   701         tx.write_security = activated
   712         return oldmode
   702         return oldmode
   713 
   703 
   714     @property
   704     @property