SAM AbstractController Class

class smarter.lib.manifest.controller.AbstractController(account, user, *args, **kwargs)[source]

Bases: ABC, AccountMixin

Abstract base class for mapping a manifest model’s metadata.kindClass to the correct Python object instance.

This controller is designed to facilitate the instantiation and management of objects based on manifest metadata, ensuring that the correct subclass is used for each manifest type. It also provides account and user context

through the AccountMixin. :param account: The account associated with the controller instance. Must be a saved model. :type account: Account :param user: The user associated with the controller instance. Must be a saved model. :type user: User :param user_profile: The user’s profile, if available. :type user_profile: optional :param request: The request object, if available. :type request: optional :param *args: Additional arguments passed to the mixin and controller. :param **kwargs: Additional arguments passed to the mixin and controller.

Usage Example:

account = Account.objects.get(pk=1)
user = User.objects.get(pk=1)
controller = MyControllerSubclass(account, user, user_profile=profile, request=request)

# Access manifest, map, and obj properties
manifest = controller.manifest
mapping = controller.map
obj_instance = controller.obj

Note

  • Both account and user must be saved instances (i.e., have a primary key).

  • This class is abstract and must be subclassed with concrete implementations of the manifest, map, and obj properties.

Warning

  • Attempting to instantiate this controller with unsaved account or user objects will raise a ValueError.

  • Subclasses must implement all abstract properties, or a NotImplementedError will be raised.

__init__(account, user, *args, **kwargs)[source]
abstract property manifest: AbstractSAMBase
abstract property map
abstract property obj: Any