# HG changeset patch # User Pierre-Yves David # Date 1364230211 -3600 # Node ID d9aaad2c52e9cee95c8db34724978fa136a66b1d # Parent 8ca4b323223c5954568ef25808bd9c645ca7fad3 [session] drop useless getter and setter for security Those function have very few user and does not anything fancy. Internal user now access tx.read/write_security directly. External user have been blessed with a writable property. They are only interested in the write part of they did not used the return of the removed function. They access it through the session since I prefer the external world to not be aware of Transaction yet. diff -r 8ca4b323223c -r d9aaad2c52e9 dataimport.py --- a/dataimport.py Wed Mar 27 19:40:09 2013 +0100 +++ b/dataimport.py Mon Mar 25 17:50:11 2013 +0100 @@ -735,8 +735,8 @@ self._nb_inserted_relations = 0 self.rql = session.execute # deactivate security - session.set_read_security(False) - session.set_write_security(False) + session.read_security = False + session.write_security = False def create_entity(self, etype, **kwargs): for k, v in kwargs.iteritems(): diff -r 8ca4b323223c -r d9aaad2c52e9 server/migractions.py --- a/server/migractions.py Wed Mar 27 19:40:09 2013 +0100 +++ b/server/migractions.py Mon Mar 25 17:50:11 2013 +0100 @@ -300,8 +300,8 @@ if self.config is not None: session = self.repo._get_session(self.cnx.sessionid) if session.cnxset is None: - session.set_read_security(False) - session.set_write_security(False) + session.read_security = False + session.write_security = False session.set_cnxset() return session # no access to session on remote instance diff -r 8ca4b323223c -r d9aaad2c52e9 server/session.py --- a/server/session.py Wed Mar 27 19:40:09 2013 +0100 +++ b/server/session.py Mon Mar 25 17:50:11 2013 +0100 @@ -497,8 +497,6 @@ :attr:`read_security` and :attr:`write_security`, boolean flags telling if read/write security is currently activated. - .. automethod:: cubicweb.server.session.Session.set_write_security - .. automethod:: cubicweb.server.session.Session.set_read_security .. automethod:: cubicweb.server.session.Session.init_security .. automethod:: cubicweb.server.session.Session.reset_security .. automethod:: cubicweb.server.session.Session.security_enabled @@ -789,11 +787,13 @@ if read is None: oldread = None else: - oldread = self.set_read_security(read) + oldread = self._tx.read_security + self._tx.read_security = read if write is None: oldwrite = None else: - oldwrite = self.set_write_security(write) + oldwrite = self._tx.write_security + self._tx.write_security = write self._tx.ctx_count += 1 return oldread, oldwrite @@ -804,34 +804,12 @@ self._clear_thread_storage(tx) else: if read is not None: - self.set_read_security(read) + self._tx.read_security = read if write is not None: - self.set_write_security(write) - - def set_read_security(self, activated): - """[de]activate read security, returning the previous value set for - later restoration. + self._tx.write_security = write - you should usually use the `security_enabled` context manager instead - of this to change security settings. - """ - oldmode = self._tx.read_security - self._tx.read_security = activated - return oldmode - - def set_write_security(self, activated): - """[de]activate write security, returning the previous value set for - later restoration. - - you should usually use the `security_enabled` context manager instead - of this to change security settings. - """ - oldmode = self._tx.write_security - self._tx.write_security = activated - return oldmode - - read_security = tx_attr('read_security') - write_security = tx_attr('write_security') + read_security = tx_attr('read_security', writable=True) + write_security = tx_attr('write_security', writable=True) running_dbapi_query = tx_attr('running_dbapi_query') # hooks activation control #################################################