Adapter mixins
The app provides several mixins that you can use to extend the behavior of your custom adapters.
These mixins are located in the anvil_consortium_manager.adapters.mixins module.
You can use these mixins by subclassing them along with the base adapter class when defining your custom adapter.
For example, to use the WorkspaceSharingAdapterMixin in a custom workspace adapter, you would do the following:
from anvil_consortium_manager.adapters.mixins import WorkspaceSharingAdapterMixin
from anvil_consortium_manager.adapters.workspace import BaseWorkspaceAdapter
class CustomWorkspaceAdapter(WorkspaceSharingAdapterMixin, BaseWorkspaceAdapter):
...
Add membership upon creation of a Managed Group
The GroupGroupMembershipAdapterMixin adds functionality for adding group members.
It requires you to define the membership_roles attribute, which should be a list of groups that should be added and the roles they should have.
For example, to create a custom Managed Group adapter using this mixin:
from anvil_consortium_manager.adapters.mixins import GroupGroupMembershipAdapterMixin, GroupGroupMembershipRole
from anvil_consortium_manager.adapters.default import DefaultManagedGroupAdapter
class CustomGroupAdapter(GroupGroupMembershipAdapterMixin, DefaultManagedGroupAdapter):
membership_roles = [
GroupGroupMembershipAdapterMixin(
# Name of the group to add as a member.
child_group_name="example-group",
# Role that this group should have.
role="MEMBER",
),
]
The `example-group` ManagedGroup will automatically be added as a MEMBER to any Managed Groups that are created.
If no groups with the name specified by child_group_name exist in the app, it will be ignored.
If the WorkspaceSharingPermission raises an exception upon validation or in API calls to AnVIL via the
WorkspaceCreate,
WorkspaceImport,
or WorkspaceClone views,
the exception will be logged and the user will be notified.