745 cnxtype indicate if this is a pyro connection or a in-memory connection |
745 cnxtype indicate if this is a pyro connection or a in-memory connection |
746 |
746 |
747 raise `AuthenticationError` if the authentication failed |
747 raise `AuthenticationError` if the authentication failed |
748 raise `ConnectionError` if we can't open a connection |
748 raise `ConnectionError` if we can't open a connection |
749 """ |
749 """ |
|
750 cnxprops = kwargs.pop('cnxprops', None) |
750 # use an internal connection |
751 # use an internal connection |
751 with self.internal_session() as session: |
752 with self.internal_session() as session: |
752 # try to get a user object |
753 # try to get a user object |
753 cnxprops = kwargs.pop('cnxprops', None) |
|
754 user = self.authenticate_user(session, login, **kwargs) |
754 user = self.authenticate_user(session, login, **kwargs) |
755 session = Session(user, self, cnxprops) |
755 session = Session(user, self, cnxprops) |
756 user._cw = user.cw_rset.req = session |
756 user._cw = user.cw_rset.req = session |
757 user.cw_clear_relation_cache() |
757 user.cw_clear_relation_cache() |
758 self._sessions[session.id] = session |
758 self._sessions[session.id] = session |
899 """this method should be used by client to: |
899 """this method should be used by client to: |
900 * check session id validity |
900 * check session id validity |
901 * update user information on each user's request (i.e. groups and |
901 * update user information on each user's request (i.e. groups and |
902 custom properties) |
902 custom properties) |
903 """ |
903 """ |
904 session = self._get_session(sessionid, setcnxset=False) |
904 user = self._get_session(sessionid, setcnxset=False).user |
905 if props is not None: |
|
906 self.set_session_props(sessionid, props) |
|
907 user = session.user |
|
908 return user.eid, user.login, user.groups, user.properties |
905 return user.eid, user.login, user.groups, user.properties |
909 |
|
910 def set_session_props(self, sessionid, props): |
|
911 """this method should be used by client to: |
|
912 * check session id validity |
|
913 * update user information on each user's request (i.e. groups and |
|
914 custom properties) |
|
915 """ |
|
916 session = self._get_session(sessionid, setcnxset=False) |
|
917 for prop, value in props.items(): |
|
918 session.change_property(prop, value) |
|
919 |
906 |
920 def undoable_transactions(self, sessionid, ueid=None, txid=None, |
907 def undoable_transactions(self, sessionid, ueid=None, txid=None, |
921 **actionfilters): |
908 **actionfilters): |
922 """See :class:`cubicweb.dbapi.Connection.undoable_transactions`""" |
909 """See :class:`cubicweb.dbapi.Connection.undoable_transactions`""" |
923 session = self._get_session(sessionid, setcnxset=True, txid=txid) |
910 session = self._get_session(sessionid, setcnxset=True, txid=txid) |