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
|
Account usage limits |
-
class
apicrud.grants.
Grants
(db_session=None, ttl=None)¶ Account usage limits
-
db_session
¶ existing db session
- Type
obj
-
ttl
¶ how long to cache a grant in memory
- Type
int
-
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 service config
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
-