Implementation of SQLAlchemy backend.
Ensures a request has permission to access the given project.
Ensures a request has permission to access the given quota class.
Ensures a request has permission to access the given user.
The backend is this module itself.
Indicates if the request context is an administrator.
Indicates if the request context is a normal user.
Query helper that accounts for context’s read_deleted field.
Parameters: |
|
---|
Produce a conjunction of expressions joined by OR.
E.g.:
from sqlalchemy import or_
stmt = select([users_table]).where(
or_(
users_table.c.name == 'wendy',
users_table.c.name == 'jack'
)
)
The or_() conjunction is also available using the Python | operator (though note that compound expressions need to be parenthesized in order to function with Python operator precedence behavior):
stmt = select([users_table]).where(
(users_table.c.name == 'wendy') |
(users_table.c.name == 'jack')
)
See also
and_()
Process the sort parameters to include default keys.
Creates a list of sort keys and a list of sort directions. Adds the default keys to the end of the list if they are not already included.
When adding the default keys to the sort keys list, the associated direction is: 1) The first element in the ‘sort_dirs’ list (if specified), else 2) ‘default_dir’ value (Note that ‘asc’ is the default value since this is the default in sqlalchemy.utils.paginate_query)
Parameters: |
|
---|---|
Returns: | list of sort keys, list of sort directions |
Raises exception.InvalidInput: | |
If more sort directions than sort keys are specified or if an invalid sort direction is specified |
Decorator to require admin request context.
The first argument to the wrapped function must be the context.
Decorator to require any user or admin context.
This does no authorization for user or project access matching, see authorize_project_context() and authorize_user_context().
The first argument to the wrapped function must be the context.
Decorator to require the specified snapshot to exist.
Requires the wrapped function to use context and snapshot_id as their first two arguments.
Decorator to require the specified volume to exist.
Requires the wrapped function to use context and volume_id as their first two arguments.
Return a constant True_ construct.
E.g.:
>>> from sqlalchemy import true
>>> print select([t.c.x]).where(true())
SELECT x FROM t WHERE true
A backend which does not support true/false constants will render as an expression against 1 or 0:
>>> print select([t.c.x]).where(true())
SELECT x FROM t WHERE 1 = 1
The true() and false() constants also feature “short circuit” operation within an and_() or or_() conjunction:
>>> print select([t.c.x]).where(or_(t.c.x > 5, true()))
SELECT x FROM t WHERE true
>>> print select([t.c.x]).where(and_(t.c.x > 5, false()))
SELECT x FROM t WHERE false
Changed in version 0.9: true() and false() feature better integrated behavior within conjunctions and on dialects that don’t support true/false constants.
See also
false()