SAM AbstractController Class
- class smarter.lib.manifest.controller.AbstractController(user_profile, *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.- Parameters:
account (Account) – The account associated with the controller instance. Must be a saved model.
user (User) – The user associated with the controller instance. Must be a saved model.
user_profile (optional) – The user’s profile, if available.
request (optional) – The request object, if available.
*args – Additional arguments passed to the mixin and controller.
**kwargs – Additional arguments passed to the mixin and controller.
Example (Usage)
-------------
code-block: (..) –
python: 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 themanifest,map, andobjproperties.warning:: (..) – Attempting to instantiate this controller with unsaved
accountoruserobjects will raise aValueError. Subclasses must implement all abstract properties, or aNotImplementedErrorwill be raised.
- abstract property manifest: AbstractSAMBase
- abstract property map