:mod:`magpie.models` ==================== .. py:module:: magpie.models Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: magpie.models.Group magpie.models.GroupPermission magpie.models.UserGroup magpie.models.GroupResourcePermission magpie.models.Resource magpie.models.UserPermission magpie.models.UserResourcePermission magpie.models.User magpie.models.ExternalIdentity magpie.models.RootFactory magpie.models.UserFactory magpie.models.Service magpie.models.PathBase magpie.models.File magpie.models.Directory magpie.models.Workspace magpie.models.Route magpie.models.RemoteResource magpie.models.RemoteResourcesSyncInfo magpie.models.RemoteResourceTreeService magpie.models.RemoteResourceTreeServicePostgresSQL Functions ~~~~~~~~~ .. autoapisummary:: magpie.models.get_session_callable magpie.models.resource_factory magpie.models.find_children_by_name .. data:: Base .. function:: get_session_callable(request) .. py:class:: Group Bases: :class:`ziggurat_foundations.models.group.GroupMixin`, :class:`Base` Mixin for Group model .. method:: get_member_count(self, db_session=None) .. method:: discoverable(self) :property: Indicates if the group is discoverable for users to self-register to it. .. py:class:: GroupPermission Bases: :class:`ziggurat_foundations.models.group_permission.GroupPermissionMixin`, :class:`Base` Mixin for GroupPermission model .. py:class:: UserGroup Bases: :class:`ziggurat_foundations.models.user_group.UserGroupMixin`, :class:`Base` Mixin for UserGroup model .. py:class:: GroupResourcePermission Bases: :class:`ziggurat_foundations.models.group_resource_permission.GroupResourcePermissionMixin`, :class:`Base` Mixin for GroupResourcePermission model .. py:class:: Resource Bases: :class:`ziggurat_foundations.models.resource.ResourceMixin`, :class:`Base` Mixin for Resource model .. attribute:: resource_type_name :annotation: :Str .. attribute:: child_resource_allowed :annotation: = True .. attribute:: resource_display_name .. method:: root_service_id(self) :property: .. method:: __acl__(self) :property: User or group that owns a resource are granted full access to it. .. py:class:: UserPermission Bases: :class:`ziggurat_foundations.models.user_permission.UserPermissionMixin`, :class:`Base` Mixin for UserPermission model .. py:class:: UserResourcePermission Bases: :class:`ziggurat_foundations.models.user_resource_permission.UserResourcePermissionMixin`, :class:`Base` Mixin for UserResourcePermission model .. py:class:: User Bases: :class:`ziggurat_foundations.models.user.UserMixin`, :class:`Base` 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 .. method:: __str__(self) Return str(self). .. py:class:: ExternalIdentity Bases: :class:`ziggurat_foundations.models.external_identity.ExternalIdentityMixin`, :class:`Base` Mixin for External Identity model - it represents oAuth(or other) accounts attached to your user object .. py:class:: RootFactory(request) Bases: :class:`object` Used to build base Access Control List (ACL) of the request user. All API and UI routes will employ this set of effective principals to determine if the user is authorized to access the pyramid view according to the ``permission`` value it was configured with. .. note:: Keep in mind that `Magpie` is configured with default permission :py:data:`magpie.constants.MAGPIE_ADMIN_PERMISSION`. Views that require more permissive authorization must be overridden with ``permission`` argument. .. seealso:: - ``set_default_permission`` within :func:`magpie.includeme` initialization steps Initialize self. See help(type(self)) for accurate signature. .. attribute:: __name__ .. attribute:: __parent__ :annotation: = .. method:: __acl__(self) :property: Administrators have all permissions, user/group-specific permissions added if user is logged in. .. py:class:: UserFactory(request) Bases: :class:`magpie.models.RootFactory` Used to build base Access Control List (ACL) of the request user. All API and UI routes will employ this set of effective principals to determine if the user is authorized to access the pyramid view according to the ``permission`` value it was configured with. .. note:: Keep in mind that `Magpie` is configured with default permission :py:data:`magpie.constants.MAGPIE_ADMIN_PERMISSION`. Views that require more permissive authorization must be overridden with ``permission`` argument. .. seealso:: - ``set_default_permission`` within :func:`magpie.includeme` initialization steps Initialize self. See help(type(self)) for accurate signature. .. method:: __getitem__(self, user_name) .. method:: __acl__(self) :property: Grant access to request user according to its relationship to context user (targeted by request path variable). If it is the same user (either from explicit name or :py:data:`magpie.constants.MAGPIE_LOGGED_USER` reserved keyword), allow :py:data:`magpie.constants.MAGPIE_LOGGED_PERMISSION` for itself to access corresponding views. If request user is unauthenticated, :py:data:`magpie.constants.MAGPIE_LOGGED_USER` or itself, also grant :py:data:`magpie.constants.MAGPIE_CONTEXT_PERMISSION` to allow access to contextually-available details. (e.g.: user can view his own information and public ones) .. py:class:: Service Bases: :class:`magpie.models.Resource` Resource of `service` type. .. attribute:: __tablename__ :annotation: = services .. attribute:: resource_id .. attribute:: resource_type_name :annotation: = service .. attribute:: __mapper_args__ .. method:: permissions(self) :property: .. method:: url(self) :property: .. method:: type(self) :property: Identifier matching ``magpie.services.ServiceInterface.service_type``. .. method:: sync_type(self) :property: Identifier matching ``magpie.cli.SyncServiceInterface.sync_type``. .. method:: by_service_name(service_name, db_session) :staticmethod: .. py:class:: PathBase Bases: :class:`object` .. attribute:: permissions .. py:class:: File Bases: :class:`magpie.models.Resource`, :class:`magpie.models.PathBase` Mixin for Resource model .. attribute:: child_resource_allowed :annotation: = False .. attribute:: resource_type_name :annotation: = file .. attribute:: __mapper_args__ .. py:class:: Directory Bases: :class:`magpie.models.Resource`, :class:`magpie.models.PathBase` Mixin for Resource model .. attribute:: resource_type_name :annotation: = directory .. attribute:: __mapper_args__ .. py:class:: Workspace Bases: :class:`magpie.models.Resource` Mixin for Resource model .. attribute:: resource_type_name :annotation: = workspace .. attribute:: __mapper_args__ .. attribute:: permissions .. py:class:: Route Bases: :class:`magpie.models.Resource` Mixin for Resource model .. attribute:: resource_type_name :annotation: = route .. attribute:: __mapper_args__ .. attribute:: permissions .. py:class:: RemoteResource Bases: :class:`ziggurat_foundations.models.base.BaseModel`, :class:`Base` Basic class that all other classes inherit from that supplies some basic methods useful for interaction with packages like: deform, colander or wtforms .. attribute:: __tablename__ :annotation: = remote_resources .. attribute:: __possible_permissions__ :annotation: = [] .. attribute:: _ziggurat_services .. attribute:: resource_id .. attribute:: service_id .. attribute:: parent_id .. attribute:: ordering .. attribute:: resource_name .. attribute:: resource_display_name .. attribute:: resource_type .. method:: __repr__(self) Return repr(self). .. py:class:: RemoteResourcesSyncInfo Bases: :class:`ziggurat_foundations.models.base.BaseModel`, :class:`Base` Basic class that all other classes inherit from that supplies some basic methods useful for interaction with packages like: deform, colander or wtforms .. attribute:: __tablename__ :annotation: = remote_resources_sync_info .. attribute:: id .. attribute:: service_id .. attribute:: service .. attribute:: remote_resource_id .. attribute:: last_sync .. method:: by_service_id(service_id, session) :staticmethod: .. method:: __repr__(self) Return repr(self). .. py:class:: RemoteResourceTreeService(service_cls) Bases: :class:`ziggurat_foundations.models.services.resource_tree.ResourceTreeService` Initialize self. See help(type(self)) for accurate signature. .. py:class:: RemoteResourceTreeServicePostgresSQL Bases: :class:`ziggurat_foundations.models.services.resource_tree_postgres.ResourceTreeServicePostgreSQL` This is necessary, because ResourceTreeServicePostgresSQL.model is the Resource class. If we want to change it for a RemoteResource, we need this class. The ResourceTreeService.__init__ call sets the model. .. data:: RESOURCE_TREE_SERVICE .. data:: REMOTE_RESOURCE_TREE_SERVICE .. data:: RESOURCE_TYPE_DICT :annotation: :Dict[Str, Type[Resource]] .. function:: resource_factory(**kwargs) .. function:: find_children_by_name(child_name, parent_id, db_session)