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:
user_profile (
UserProfile) – The user profile that owns the controlled resource. Its account and user are the controller’s account and user.args (
Any) – Passed on toAccountMixin.kwargs (
Any) – Passed on toAccountMixin, e.g.request.
Usage Example:
user_profile = UserProfile.get_cached_object(user=user) controller = MyControllerSubclass(user_profile, request=request) # Access manifest, map, and obj properties manifest = controller.manifest mapping = controller.map obj_instance = controller.obj
Note
This class is abstract and must be subclassed with concrete implementations of the
manifest,map, andobjproperties.Warning
A subclass that does not implement all of the abstract properties cannot be instantiated.
- __init__(user_profile, *args, **kwargs)[source]
Initialize the account context from the user profile, with one AccountMixin initialization.
- Parameters:
user_profile (
UserProfile) – The user profile that owns the controlled resource.args (
Any) – Passed on toAccountMixin.kwargs (
Any) – Passed on toAccountMixin.
- abstract property manifest: AbstractSAMBase | None
The Pydantic manifest of the controlled resource, or None if there is none yet; subclasses implement it.