Anuket is an opiniated Python web framework based on Pyramid.
Models for the Anuket application.
SQLAlchemy model definition for authentification.
AuthGroup table and model definition.
Define the database auth_group table for the users groups and a method to query the table. This table is used used for ACLs principals.
AuthUser table and model definition.
Define the database auth_user table for the authenticated users and the methods for querring the table or check the validity of the password.
Query the auth_user table by user_id.
Parameters: | user_id – the user id |
---|---|
Returns: | a sqlalchemy.orm.query.Query object |
Query the auth_user table by username.
Parameters: | username (unicode) – the user username |
---|---|
Returns: | a sqlalchemy.orm.query.Query object |
Query the auth_user table by email.
Parameters: | username (unicode) – the user email |
---|---|
Returns: | a sqlalchemy.orm.query.Query object |
Check the user password.
Check if the submited password for username is the same than the encrypted one recorded in the database. Return None if the username did not exist.
Parameters: |
|
---|---|
Returns: | True if the password is correct. false if incorect |
Return type: | boolean |
SQLAlchemy model definition for database migration with Alembic.
Pyramid root factory model.
Views callables for the Anuket application.
Main views for the application.
Render the root pages.
Render the home page, the login page and 404 not found page.
Parameters: | request – a pyramid.request object |
---|
Redirect the 403 forbiden view.
Authenticated user with not enought permission are redirected to the home page. Non-autenthicaded users are redirected to the login page. A corresponding flash message is also added to the error message queue.
Parameters: | request – a pyramid.request object |
---|
Render the login form.
Display an empty login form or check the submited credentials with the ones from the database. Add a success flash message, an userid in the cookies and redirect to the home page if the credentials are goods. Add an error flash message and display again the login form if the credentials are wrong.
Parameters: | request – a pyramid.request object |
---|
Admin tools views for the application.
Admin tools for user management.
Render the add user form page.
Display an empty user form or validate the user submited form. If the form is validated then add the user datas to the database and a success flash message. If the form is not valid, then display again the form with validation errors. Return also a list of groups to use in the group select form.
Parameters: | request – a pyramid.request object |
---|
Delete an user.
Seek the database for the user datas based on user_id used in the route. If the user did not exist then add an error flash message and redirect to the user list. If the user exist then delete the user in the database, add a warning flash message and then redirect to the user list.
Parameters: | request – a pyramid.request object |
---|
Render the edit user form page.
Seek the database for the user datas based on user_id used in the route. If the user did not exist then add an error flash message and redirect to the user list. If the user exist then render the user form filled with the user datas. If the form is validated then change the user datas to the database and add success flash message. If the form is not valid, then display again the form with validation errors. Return also a list of groups to use in the group select form.
Parameters: | request – a pyramid.request object |
---|
Render the user list page.
Return a paged user list from the database. The paged list can be ordered by username, first name or last name. Add an error flash message if the list is empty. Return also basic users statistics.
Parameters: | request – a pyramid.request object |
---|
Render the show user datas page.
Seek the database for the user datas based on user_id used in the route. If the user did not exist then add an error flash message and redirect to the user list. If the user exist then return his datas.
Parameters: | request – a pyramid.request object |
---|
Render the change password form page.
Seek the database for the user datas based on user_id used in the route. If the user did not exist then add an error flash message and redirect to the user list. If the user exist then render an empty password form. If the form is validated then change the user password in the database and add success flash message. If the form is not valid, then display again the form with validation errors.
Parameters: | request – a pyramid.request object |
---|
Command line scripts for the Anuket application.
Script to initialize the Anuket database.
Create the database using the configuration from the .ini file passed as a positional argument.
Script to backup the Anuket database.
Script for upgrading the Anuket database with Alembic.
Upgrade the database using the configuration from the .ini file passed as a positional argument.
Internal library for the Anuket application.
Alembic utilities to use with database scripts.
Define a message factory and a locale negotiator.
FormEncode validators.
Messages
Messages
Messages
Unique username validator.
Messages
Unique email validator.
Messages
Secure password validator.
Messages
Authentification related utilities.
Groupfinder callback for authentification policy.
Return the groupname (principal) of an authenticated user form the database. Return None if the user do not exist.
Parameters: |
|
---|---|
Returns: | the user groupname or None |
Pyramid event subscribers.
Renderers globals event subscriber.
Add globals to the renderer. Add _, localizer and brand_name globals.
Parameters: | event – a pyramid.event.BeforeRender object |
---|
Localization event subscriber.
Automaticaly translate strings in the templates.
Parameters: | event – a pyramid.event.NewRequest object |
---|
CSRF validation event subscriber.
If the POST forms do not have a CSRF token, or an invalid one then user is logged out and the forbident view is called.
Parameters: | event – a pyramid.event.NewRequest object |
---|---|
Raises HTTPForbidden: | |
if the CSRF token is None or invalid |