Adapters¶
The authomatic.login() function needs access to functionality like getting the URL of the handler where it is being called, getting the request params, headers and cookies and writing the body, headers and status to the response.
Since implementation of these features varies across Python web frameworks, the Authomatic library uses adapters to unify these differences into a single interface.
Available Adapters¶
If you are missing an adapter for the framework of your choice, which is very likely, since currently there are only the Webapp2Adapter and WerkzeugAdapter available, please consider a contribution to this module by implementing one. Its very easy and shouldn’t take you more than a few minutes.
Implementing an Adapter¶
Implementing an adapter for a Python web framework is pretty easy.
Do it by subclassing the BaseAdapter abstract class. There are only seven members that you need to implement.
Moreover if your framework is based on the WebOb library you can subclass the WebObBaseAdapter and you only need to override the constructor.
- class authomatic.adapters.BaseAdapter[source]¶
Base class for platform adapters
Defines common interface for WSGI framework specific functionality.
- url[source]¶
Must return the url of the actual request including path but without query and fragment
Returns: str
- write(value)[source]¶
Must write specified value to response.
Parameters: value (str) – String to be written to response.