def get_raven_client(): from raven.base import Raven if Raven: dsns = list(Raven._transport_cache.keys()) if any((Raven._transport_cache[dsn]._transport_cls != ThreadedRequestsHTTPTransport for dsn in dsns)): Raven._transport_cache.clear() for dsn in dsns: Raven.set_dsn(dsn, ThreadedRequestsHTTPTransport) return Raven
def authentication_callback(user_id, request): "This is how pyramid knows the user's permissions" connection = User.default_db.connection() connection.info['userid'] = user_id discussion = discussion_from_request(request) discussion_id = discussion.id if discussion else None # this is a good time to tell raven about the user from raven.base import Raven if Raven: if user_id: Raven.user_context({'user_id': user_id}) if discussion_id: Raven.context.merge({'discussion_id': discussion_id}) return get_roles(user_id, discussion_id)
def authentication_callback(user_id, request): "This is how pyramid knows the user's permissions" connection = User.default_db.connection() connection.info['userid'] = user_id discussion_id = request.discussion_id() # this is a good time to tell raven about the user from raven.base import Raven if Raven: if user_id: Raven.user_context({'user_id': user_id}) if discussion_id: Raven.context.merge({'discussion_id': discussion_id}) # Check that the user exists if not request.user: return None return request.roles