pywebtools.pyramid.auth.views – Authentication Framework Views

Views that implement the backend for the authentication framework. The current_user() provides a decorator that automatically adds the currently logged in user (or an anonymous not-logged in user) into the current request.

class pywebtools.pyramid.auth.views.ActionSchema(*args, **kw)
The ActionSchema handles the validation of
user action requests.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
action = None

The action to apply

confirm = None

Whether the user has confirmed the action

q = None

Optional query parameter for the redirect

start = None

Optional start parameter for the redirect

status = None

Optional status parameter for the redirect

user_id = None

User ids to apply the action to

class pywebtools.pyramid.auth.views.EditSchema(*args, **kw)
The class:~wte.views.user.EditSchema handles the validation of
changes to the User.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
display_name = None

Updated name

email = None

Updated e-mail address

password = None

Updated password

class pywebtools.pyramid.auth.views.ForgottenPasswordSchema(*args, **kw)
The ForgottenPasswordSchema handles the
validation of forgotten password requests.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
email = None

E-mail to request a new password or validation token for

return_to = None

URL to redirect to after a successful password request

class pywebtools.pyramid.auth.views.LoginSchema(*args, **kw)
The LoginSchema handles the validation of a
login request.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
email = None

E-mail address to log in with

password = None

Password to log in with

return_to = None

URL to redirect to after a successful login (optional)

class pywebtools.pyramid.auth.views.RegisterSchema(*args, **kw)
The RegisterSchema handles the validation of
registration requests. s

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
email = None

E-mail address to register with

email_confirm = None

Confirmation of the registration e-mail address

name = None

Name of the registering user

return_to = None

URL to redirect to after a successful registration (optional)

class pywebtools.pyramid.auth.views.ResetPasswordSchema(*args, **kw)
The ResetPasswordSchema handles the validation of
password reset requests.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
password = None

New password

password_confirm = None

Updated password

pywebtools.pyramid.auth.views.action(request)

Handles the /users/action URL, applying the given action to the list of selected users. Requires that the current User has the “admin.users.view” Permission.

pywebtools.pyramid.auth.views.confirm(request)

Handles the “users.confirm” URL, validating that the user with the {token} has access to the e-mail address they provided.

On a successful confirmation, calls the “user.validated” callback with three parameters: the current request object, the new User, and the validation TimeToken.

If overriding the URL, the URL must only have a {token} parameter.

pywebtools.pyramid.auth.views.create_user_crumbs(request, crumbs)

Creates the base-list of breadcrumbs, depending on the current users authorisation level.

pywebtools.pyramid.auth.views.delete(request)

Handles the “/users/{uid}/delete” URL, providing the form and backend functionality for deleting a User. Also deletes all the data that is linked to that User.

pywebtools.pyramid.auth.views.edit(request)

Handles the “/users/{uid}/edit” URL, providing the form and backend functionality to update the user’s profile.

pywebtools.pyramid.auth.views.forgotten_password(request)

Handles the “user.forgotten_password” URL, showing the form where the user can provide their e-mail address.

If the e-mail address provided does not match any known e-mail address, calls the “user.password_reset_failed” callback with the current request. If the e-mail address is known and the User status is “unconfirmed”, calls the “user.created” callback with the current request, the User, and a new TimeToken. If the User status is “active”, calls the “user.password_reset” callback with the current request, the User, and a new TimeToken.

Uses either the return_to parameter in the request to redirect on success or the “user.forgotten_password” redirection route.

pywebtools.pyramid.auth.views.login(request)

Handles the “user.login” URL, checking the submitted username and password against the stored User and setting the necessary session variables if the login is successful.

Uses either the return_to parameter in the request to redirect on success or the “user.login” redirection route, with parameter replacement “{uid}” will be replaced with the logged in user’s identifier.

pywebtools.pyramid.auth.views.logout(request)

Handles the “user.logout” URL and deletes the current session, thus logging the user out.

Redirects to the “user.logout” redirection route.

pywebtools.pyramid.auth.views.permissions(request)

Handles the “/users/{uid}/permissions” URL, providing the form and backend functionality for setting the Permission and PermissionGroup that the User belongs to.

pywebtools.pyramid.auth.views.redirect(request, redirect_id, **kwargs)

Handles post-action redirects. If the redirection value is a string, uses that as the redirection route name. If it is a dictionary, then the value of the “route” key is used as the route name and the value of the “params” key is passed to the request.route_url function as keyword arguments. Uses replace_kwargs() to allow dynamic data.

Parameters:
  • request (Request) – The request to use for redirection
  • redirect_id (str) – The identifier of the redirect to execute
  • kwargs – Keyword arguments to use for replacements
pywebtools.pyramid.auth.views.register(request)

Handles the “user.register” URL, displaying the registration form or if data is POSTed, creating a new user.

On a successful registration, calls the “user.created” callback with three parameters: the current request object, the new User, and the validation TimeToken.

On a successful registration, redirects to the “user.register” redirection route.

pywebtools.pyramid.auth.views.replace_kwargs(value, kwargs)

Replace any keyword arguments in value with the value specified in kwargs. If the keyword argument does not exist in kwargs, replace with an empty string.

The function can handle both strings and dictionaries. In the case of dictionaries, both the keys and values are replaced.

Params value:The value to replace
Parameters:kwargs (dict) – The replacement values
Returns:The value with all keyword arguments replaced
pywebtools.pyramid.auth.views.reset_password(request)

Handles the “user.forgotten_password” URL, showing the form where the user can provide their e-mail address.

If token is valid, calls the “user.password_reset_complete” callback with the current request and the User.

Uses either the return_to parameter in the request to redirect on success or the “user.login” redirection route, with parameter replacement “{uid}” will be replaced with the logged in user’s identifier.

If overriding the URL, the URL must only have a {token} parameter.

pywebtools.pyramid.auth.views.users(request)

Handles the /users URL, displaying all users if the current User has the “admin.users.view” Permission.

pywebtools.pyramid.auth.views.view(request)

Handles the “/users/{uid}” URL, showing the user’s profile.