1 Entities and Attributes
2 =======================
4 One of the core concepts in philo is the relationship between the :class:`Entity` and :class:`Attribute` classes. :class:`Attribute`\ s represent an arbitrary key/value pair by having one :class:`GenericForeignKey` to an :class:`Entity` and another to an :class:`AttributeValue`.
9 .. function:: register_value_model(model)
10 .. function:: unregister_value_model(model)
12 Helper functions to register/unregister a model as a valid content type for a :class:`ForeignKeyValue` or :class:`ManyToManyValue`.
18 .. class:: AttributeValue
20 This is an abstract base class for models that can be used as values for :class:`Attribute`\ s. See the code for examples of implementations.
22 .. attribute:: attribute_set
24 :class:`GenericRelation` back to :class:`Attribute`
26 .. method:: set_value(value)
28 Interpret ``value`` and set the appropriate fields so that the value displayed to the world is equivalent to ``value``.
30 .. method:: value_formfields(**kwargs)
32 Define any formfields that would be used to construct an instance of this value.
34 .. method:: construct_instance(**kwargs)
36 Apply cleaned data from the formfields generated by valid_formfields to oneself.
40 Represents an arbitrary key/value pair attached to a model.
44 :class:`GenericForeignKey` to anything.
48 :class:`GenericForeignKey` to a subclass of :class:`AttributeValue`.
52 :class:`CharField` containing a key (up to 255 characters) consisting of alphanumeric characters and underscores.
56 A class that simplifies access to related attributes.
58 .. attribute:: attribute_set
60 :class:`GenericRelation` back to :class:`Attribute`.
62 .. attribute:: attributes
64 Property that returns a dictionary-like object which can be used to retrieve :class:`Attribute`\ s values directly.
68 >>> attr = entity.attribute_set.get(key='spam')
71 >>> entity.attributes['spam']