rr- 2e4e77791d back/auth: refactor authentication
- Removed transaction manager
- Each request gets its own session via DbSession middleware
- Moved authentication details to Authenticator middleware
- Fixed cyclic dependency between AuthService and UserService
2016-03-28 22:31:08 +02:00

15 lines
495 B
Python

''' Exports DbSession. '''
class DbSession(object):
''' Attaches database session to the context of every request. '''
def __init__(self, session_factory):
self._session_factory = session_factory
def process_request(self, request, response):
''' Executed before passing the request to the API. '''
request.context['session'] = self._session_factory()
def process_response(self, request, response, resource):
request.context['session'].close()