SAM AbstractController Class
- class smarter.lib.manifest.controller.AbstractController(account, user, *args, **kwargs)[source]
Bases:
ABC,AccountMixinAbstract base class for mapping a manifest model’s
metadata.kindClassto 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
accountandusermust be saved instances (i.e., have a primary key).This class is abstract and must be subclassed with concrete implementations of the
manifest,map, andobjproperties.
Warning
Attempting to instantiate this controller with unsaved
accountoruserobjects will raise aValueError.Subclasses must implement all abstract properties, or a
NotImplementedErrorwill be raised.
- abstract property manifest: AbstractSAMBase
- abstract property map