stalker.models.mixins.TargetEntityTypeMixin¶
-
class
stalker.models.mixins.TargetEntityTypeMixin(target_entity_type=None, **kwargs)[source]¶ Bases:
objectAdds target_entity_type attribute to mixed in class.
Parameters: target_entity_type – The target entity type which this class is designed for. Should be a class or a class name.
For example:
from stalker import SimpleEntity, TargetEntityTypeMixin, Project class A(SimpleEntity, TargetEntityTypeMixin): __tablename__ = “As” __mapper_args__ = {“polymorphic_identity”: “A”} def __init__(self, **kwargs): super(A, self).__init__(**kwargs) TargetEntityTypeMixin.__init__(self, **kwargs) a_obj = A(target_entity_type=Project)The
a_objwill only be accepted byProjectinstances. You can not assign it to any other class which accepts aTypeinstance.To control the mixed-in class behaviour add these class variables to the mixed in class:
- __nullable_target__ : controls if the target_entity_type can be
- nullable or not. Default is False.
- __unique_target__ : controls if the target_entity_type should be
- unique, so there is only one object for one type. Default is False.
Methods
__init__([target_entity_type])Attributes
target_entity_type