apicrud.grants¶
grants.py
- Grants
An account’s usage limits are specified here in the grants table; the free-service tier is defined and passed in via load_defaults(). Records in grants table are owned by administrator-level user. If a record matches a user uid, the default grant name=value is overridden.
created 27-may-2019 by richb@instantlinux.net
Classes
|
Role-based access control |
|
Account usage limits |
|
Difference between two datetime values. |
-
class
apicrud.grants.
Grants
(models, db_session=None, ttl=None)¶ Account usage limits
- Parameters
models (obj) – the models file object
db_session (obj) – existing db session
ttl (int) – how long to cache a grant in memory
-
get
(name, uid=None)¶ Get the cached value of a named grant, if it hasn’t expired Note that if any grant assigned to a uid expires before others, the earliest expiration applies to all the uid’s grants
- Parameters
name (str) – name of a grant, as defined in config.py
uid (str) – user ID
- Returns
granted limit
- Return type
value
-
load_defaults
(defaults)¶ Load default values from a dict of keyword: value pairs
- Parameters
defaults (dict) – new defaults
-
uncache
(uid)¶ Remove grants from cache, any time a user’s status changes
- Parameters
uid (str) – user ID