Returns the value of the requested argument either via a URL argument or through the input element of a form. If the requested parameter is not provided this function will return None.

Arguments
name
The name of the argument or the form's input name.
cast
Type of the argument that the param should be casted to. If you want to cast to a bool it will return True to any of these values: true, yes or 1.

If the &next argument is provided in the URL then this function will return its value.

If the &next argument is not present then it will return the referrer URL, but only if it's from the same domain. Very useful when you want to return to the same page that you've been before, after completing a certain action, like sign in page or edit of the form.

When nothing is present it will simply return the URL of the welcome page.

...

...

Same as flask.jsonify(), which means it creates a Response with the JSON representation of the given arguments with an application/json mimetype. The arguments to this function are the same as to the dict constructor.

In addition if callback argument is provided in the request then it will return a response with the JSONP representation.

Demo

Visit the following URL to check it in action: gae-init.appspot.com/api/v1/user/?callback=foo

Returns True if the instance is iterable, False otherwise.

...

...

Simple wrapper for uuid.uuid4().hex to generate a Universal Unique Identifier (UUID) without any separators.

Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts separators to hyphens. Also strips leading and trailing whitespace.

Checks if the given username contains only alphanumeric characters and dots as separators.

Returns the best guess for a name from a given email.

Generates the the password hash based on the user_db and the given password.

Takes the current URL request and updates only the argument name with the given value. If the value is omitted then that argument will be removed from the request. This function is intended to be used in the Jinja2 templates and currently it's being used in utils.order_by_link() and utils.filter_by_link().

Arguments
name
The name of the argument to be updated.
value
Optional new value for the given argument. When omitted, the argument will be removed if any.
ignore
Optional list of arguments that will be ignored and removed from the generated request. Sometimes it is needed when in the original request the cursor is present and it will be invalid if some of the other arguments will have a different value.

...

Lambda function that strips a given string, which is used as a filter in the Flask-WTF form fields.

Lambda function that transforms to lowercase and strips a given string, which is used as a filter in the Flask-WTF form fields.

Lambda function that sorts a list of choices, which is used as a filter in the Flask-WTF form fields.

Sends an email notification to the feedback email if it set in the admin config settings. The email is sent as a background task, using the deferred library, to avoid possible errors that could be produced due to quota limits or anything else. The brand name of the application will be used as a name of the sender and prefixed to the subject of the email.

...

...

...

...

The numerical ID of the authenticated user if there is one, otherwise 0.

The user_key of the authenticated user if there is one, otherwise None. If you want to make sure that this function will return a user_key use one of the decorators.

The User entity model of the authenticated user if there is one, otherwise None. If you want to make sure that this function will return a user_db use one of the decorators.

In templates you can get access to this variable through {{current_user.user_db}}. So if you would like to display the name of the currently signed in user somewhere you would use it like: {{current_user.user_db.name}}.

Checks if there is an authenticated user or not.

...

...

If you need more fine-grained control over who can access what, you can use the @auth.permission_required(permission) decorator. It will only allow accesses to the decorated function by registered users who were given that permission (or admins). It works like this:

@app.route('/moderate')
@auth.permission_required('moderator')
def moderate():
  return flask.render_template(...)

This will automagically register 'moderator' as an available permission which an admin can assign to individual users via the user list. For convenience you can leave the permission string empty, which will cause the permission to be named as the decorated function (so @auth.permission_required() would introduce and check for the permission 'moderate' in the example above).

If methods is specified, the decorator will only enforce the given permission for requests with a method as in methods (e.g., @auth.permission_required('foo_w', methods=['POST']) will only check the user for permission 'foo_w' in POST requests but won't restrict other requests). If methods is None (default), the permissions will be enforced on all requests regardless of their method.

Several uses of this decorator can be combined as in the example below. This only allows access to endpoint in GET requests if the user has 'foo_r' permission. For POST requests the user needs both 'foo_r' and 'foo_w':

@app.route('/endpoint/')
@auth.permission_required('foo_r')
@auth.permission_required('foo_w', methods=['POST'])
def endpoint():
  pass

Typical usecases:

  • allow everyone to read, restrict write to a few users: just leave out the second line
  • allow all logged in users to read, restrict write to a few users: replace the second line with @auth.login_required

The order of the statements is not important as the permissions are wrapped around each other. All of the permission guards have to be passed in order to reach endpoint. Passing one of them does not skip the others.

The @auth.cron_required decorator is used to enforce access constraints on an endpoint used for scheduled tasks.

This decorator checks for the presence of the X-Appengine-Cron: true header that GAE automatically adds to a scheduled task request.

It also checks for admin permissions, which allows for testing of scheduled tasks.

For more information on how to create scheduled tasks in GAE, see Scheduling Tasks With Cron for Python

All the variables that are defined in the config.py can be also used in the in the Jinja2 templates as well. For example if you want to refer to the brand name or a current version you could use it like: {{config.CONFIG_DB.brand_name}} or {{config.CURRENT_VERSION_ID}} respectively.

It's a copy of the single entity of the Config model. For example if you want to use the brand_name you should use it like: config.CONFIG_DB.brand_name, instead of accessing it directly from the Model.

Is a secret_key that is used by Flask, to sign cookies and other things. It's auto generated but you can change it through the admin config.

Full version ID of the deployed application.

Version name of the deployed application.

Timestamp of the deployed application.

Datetime of the deployed application.

Application ID of the deployed application.

True if running on local machine, False otherwise.

True if running on production server, False otherwise.

Same as config.DEVELOPMENT and it's used in Flask configuration.

The default limit for fetching datastore entities, used in the util.retrieve_dbs.

...

The default separator for parsing the tags with parse_tags.

Generates a link that will update only the &order= argument of the query to the correct value depending on the possible sort order that is already applied. If that particular order is already applied then it will be clearly indicated with the correct icon.

Arguments
property
The name of the entity's property.
title
The title that will appear to the end user.
ignore
Optional list of arguments that will be ignored and removed from the generated request. Sometimes it is needed when in the original request the cursor is present and it will be invalid if some of the other arguments will have a different value.

Examples & Demo

Check how it is used in user_list.html and play with orders in User List.

Generates a link that will add (or replace) &property=value to the current request or will remove it if it's already there. Optionally instead of showing the actual value it is possible to show an icon. The icon is more appropriate when filtering by boolean properties.

Arguments
property
The name of the entity's property.
value
The value to be applied to the filter.
icon
Optional name for the icon instead that will be shown instead of the value.
ignore
Optional list of arguments that will be ignored and removed from the generated request. Sometimes it is needed when in the original request the cursor is present and it will be invalid if some of the other arguments will have a different value.

Examples & Demo

Check how it is used in user_list.html and play with filters in User List.

...

...

Renders the correct brand icon for a known authentication id and if not found then it will render a question mark.

Arguments

auth_id
The authentication id that has the form of {brand}_{id}.

Renders multiple authentication icons based on the given list. It uses the auth_icon to render the individual icons.

Arguments
auth_ids
List of authentication ids that each item has the form of {brand}_{id}.

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...