Models¶
UserMixin¶
-
class
ziggurat_foundations.models.user.
UserMixin
¶ Base mixin for User object representation. It supplies all the basic functionality from password hash generation and matching to utility methods used for querying database for users and their permissions or resources they have access to. It is meant to be extended with other application specific properties
ExternalIdentityMixin¶
-
class
ziggurat_foundations.models.external_identity.
ExternalIdentityMixin
¶ Mixin for External Identity model - it represents oAuth(or other) accounts attached to your user object
GroupMixin¶
GroupPermissionMixin¶
-
class
ziggurat_foundations.models.group_permission.
GroupPermissionMixin
¶ Mixin for GroupPermission model
UserPermissionMixin¶
-
class
ziggurat_foundations.models.user_permission.
UserPermissionMixin
¶ Mixin for UserPermission model
UserGroupMixin¶
-
class
ziggurat_foundations.models.user_group.
UserGroupMixin
¶ Mixin for UserGroup model
GroupResourcePermissionMixin¶
-
class
ziggurat_foundations.models.group_resource_permission.
GroupResourcePermissionMixin
¶ Mixin for GroupResourcePermission model
UserResourcePermissionMixin¶
-
class
ziggurat_foundations.models.user_resource_permission.
UserResourcePermissionMixin
¶ Mixin for UserResourcePermission model
ResourceMixin¶
get_db_session¶
-
ziggurat_foundations.models.base.
get_db_session
(session=None, obj=None)¶ utility function that attempts to return sqlalchemy session that could have been created/passed in one of few ways:
- It first tries to read session attached to instance if object argument was passed
- then it tries to return session passed as argument
- finally tries to read pylons-like threadlocal called DBSession
- if this fails exception is thrown
Parameters: - session –
- obj –
Returns:
BaseModel¶
-
class
ziggurat_foundations.models.base.
BaseModel
¶ Basic class that all other classes inherit from that supplies some basic methods useful for interaction with packages like: deform, colander or wtforms
-
delete
(db_session=None)¶ Deletes the object via session, this will permanently delete the object from storage on commit
Parameters: db_session – Returns:
-
get_appstruct
()¶ return list of tuples keys and values corresponding to this model’s data
-
get_db_session
(session=None)¶ Attempts to return session via get_db_session utility function
get_db_session()
Parameters: session – Returns:
-
get_dict
(exclude_keys=None, include_keys=None)¶ return dictionary of keys and values corresponding to this model’s data - if include_keys is null the function will return all keys
Parameters: exclude_keys – (optional) is a list of columns from model that should not be returned by this function :param include_keys: (optional) is a list of columns from model that should be returned by this function :return:
-
persist
(flush=False, db_session=None)¶ Adds object to session, if the object was freshly created this will persist the object in the storage on commit
Parameters: - flush – boolean - if true then the session will be flushed instantly
- db_session –
Returns:
-
populate_obj
(appstruct, exclude_keys=None, include_keys=None)¶ updates instance properties for column names that exist for this model and are keys present in passed dictionary
Parameters: - appstruct – (dictionary)
- exclude_keys – (optional) is a list of columns from model that
should not be updated by this function :param include_keys: (optional) is a list of columns from model that should be updated by this function :return:
-
populate_obj_from_obj
(instance, exclude_keys=None, include_keys=None)¶ updates instance properties for column names that exist for this model and are properties present in passed dictionary
Parameters: - instance –
- exclude_keys – (optional) is a list of columns from model that
should not be updated by this function :param include_keys: (optional) is a list of columns from model that should be updated by this function :return:
-