dokomoforms.handlers package¶
Subpackages¶
Submodules¶
dokomoforms.handlers.auth module¶
Authentication handlers.
-
class
dokomoforms.handlers.auth.
CheckLoginStatus
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
An endpoint for the application to check login status.
-
class
dokomoforms.handlers.auth.
GenerateToken
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
GET your token here. GETting twice resets the token.
-
class
dokomoforms.handlers.auth.
Login
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
POST here to verify the assertion generated by Mozilla Persona.
-
post
()[source]¶ POST to Mozilla’s verifier service.
Accepts: { “assertion”: <assertion> }
Then, POSTS to https://verifier.login.persona.org/verify to verify that the assertion is valid. If so, attempts to log the user in by e-mail.
Responds with: 200 OK { “email”: <e-mail address> }
Raises tornado.web.HTTPError: 400 Bad Request if the assertion is not verified 422 Unprocessable Entity if the e-mail address is not associated with a user account.
-
-
class
dokomoforms.handlers.auth.
Logout
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
POST here to log out.
dokomoforms.handlers.debug module¶
Pages pertaining to debug-specific functionality.
-
class
dokomoforms.handlers.debug.
DebugLoginHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Use this page to log in as any existing user.
-
class
dokomoforms.handlers.debug.
DebugLogoutHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Log out by visiting this page.
-
class
dokomoforms.handlers.debug.
DebugPersonaHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For testing purposes there’s no need to hit the real URL.
No need for this...
-
class
dokomoforms.handlers.debug.
DebugRevisitHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For testing purposes there’s no need to hit Revisit proper.
Debug endpoint.
-
class
dokomoforms.handlers.debug.
DebugToggleRevisitHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For turning the fake Revisit endpoint off and on.
-
class
dokomoforms.handlers.debug.
DebugToggleRevisitSlowModeHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For toggling slow mode.
-
class
dokomoforms.handlers.debug.
DebugUserCreationHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Use this page to create a user.
dokomoforms.handlers.root module¶
Administrative handlers.
-
class
dokomoforms.handlers.root.
Index
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The root URL.
-
class
dokomoforms.handlers.root.
NotFound
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
This is the “default” handler according to Tornado.
dokomoforms.handlers.util module¶
Useful reusable functions for handlers, plus the BaseHandler.
-
class
dokomoforms.handlers.util.
BaseAPIHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The Tornado handler class for API resource classes.
-
api_root_path
¶ The API URL up to the version number.
-
api_version
¶ The API version.
Do not check XSRF for an API request (usually).
-
-
class
dokomoforms.handlers.util.
BaseHandler
(application, request, **kwargs)[source]¶ Bases:
tornado.web.RequestHandler
The base class for handlers.
Makes the database session and current user available.
-
current_user_model
¶ Return the current logged in User, or None.
-
get
(*args, **kwargs)[source]¶ 404 unless this method is overridden.
The presence of this GET method means that endpoints which only accept POST are hidden from browsers.
Raises tornado.web.HTTPError: 404 Not Found
-
get_current_user
() → str[source]¶ Make current_user accessible.
You probably shouldn’t override this method. It makes {{ current_user }} accessible to templates and self.current_user accessible to handlers.
Returns: a string containing the user name.
-
prepare
()[source]¶ Default behavior before any HTTP method.
By default, just sets up the XSRF token.
-
session
¶ The SQLAlchemy session for interacting with the models.
Returns: the SQLAlchemy session
-
user_default_language
¶ Return the logged-in User’s default language, or None.
-
Module contents¶
All the Tornado RequestHandlers used in Dokomo Forms.
-
class
dokomoforms.handlers.
Index
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The root URL.
-
class
dokomoforms.handlers.
NotFound
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
This is the “default” handler according to Tornado.
-
class
dokomoforms.handlers.
Login
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
POST here to verify the assertion generated by Mozilla Persona.
-
post
()[source]¶ POST to Mozilla’s verifier service.
Accepts: { “assertion”: <assertion> }
Then, POSTS to https://verifier.login.persona.org/verify to verify that the assertion is valid. If so, attempts to log the user in by e-mail.
Responds with: 200 OK { “email”: <e-mail address> }
Raises tornado.web.HTTPError: 400 Bad Request if the assertion is not verified 422 Unprocessable Entity if the e-mail address is not associated with a user account.
-
-
class
dokomoforms.handlers.
Logout
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
POST here to log out.
-
class
dokomoforms.handlers.
GenerateToken
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
GET your token here. GETting twice resets the token.
-
class
dokomoforms.handlers.
AdminHomepageHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The endpoint for the main Administrator interface.
-
class
dokomoforms.handlers.
CheckLoginStatus
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
An endpoint for the application to check login status.
-
class
dokomoforms.handlers.
ViewSurveyHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The endpoint for getting a single survey’s admin page.
-
class
dokomoforms.handlers.
ViewSurveyDataHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The endpoint for getting a single survey’s data page.
-
class
dokomoforms.handlers.
ViewUserAdminHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The endpoint for getting the user administration admin page.
-
class
dokomoforms.handlers.
ViewSubmissionHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The endpoint for viewing a submission.
-
class
dokomoforms.handlers.
EnumerateHomepageHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
The endpoint for the main Enumerator interface.
-
class
dokomoforms.handlers.
Enumerate
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
View and submit to a survey.
-
class
dokomoforms.handlers.
EnumerateTitle
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
View and submit to a survey identified by title.
-
class
dokomoforms.handlers.
DebugUserCreationHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Use this page to create a user.
-
class
dokomoforms.handlers.
DebugLoginHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Use this page to log in as any existing user.
-
class
dokomoforms.handlers.
DebugLogoutHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Log out by visiting this page.
-
class
dokomoforms.handlers.
DebugPersonaHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For testing purposes there’s no need to hit the real URL.
No need for this...
-
class
dokomoforms.handlers.
DebugRevisitHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For testing purposes there’s no need to hit Revisit proper.
Debug endpoint.
-
class
dokomoforms.handlers.
DebugToggleRevisitHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For turning the fake Revisit endpoint off and on.
-
class
dokomoforms.handlers.
DebugToggleRevisitSlowModeHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
For toggling slow mode.
-
class
dokomoforms.handlers.
DemoUserCreationHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Use this page to log in as the demo user.
-
class
dokomoforms.handlers.
DemoLogoutHandler
(application, request, **kwargs)[source]¶ Bases:
dokomoforms.handlers.util.BaseHandler
Log out by visiting this page.