One of the core concepts in Philo is the relationship between the Entity and Attribute classes. Attributes represent an arbitrary key/value pair by having one GenericForeignKey to an Entity and another to an AttributeValue.
Attributes exist primarily to let arbitrary data be attached to arbitrary model instances without altering the database schema and without guaranteeing that the data will be available on every instance of that model.
Generally, Attributes will not be accessed as models; instead, they will be accessed through the Entity.attributes property, which allows direct dictionary getting and setting of the value of an Attribute with its key.
GenericForeignKey to anything (generally an instance of an Entity subclass).
GenericForeignKey to an instance of a subclass of AttributeValue as determined by the attribute_value_limiter.
CharField containing a key (up to 255 characters) consisting of alphanumeric characters and underscores.
Given a value and a value class, sets up self.value appropriately.
This is an abstract base class for models that can be used as values for Attributes.
AttributeValue subclasses are expected to supply access to a clean version of their value through an attribute called “value”.
Given a value, sets the appropriate fields so that it can be correctly stored in the database.
Returns any formfields that would be used to construct an instance of this value.
Returns: | A dictionary mapping field names to formfields. |
---|
Applies cleaned data from the formfields generated by valid_formfields to oneself.
An instance of ContentTypeSubclassLimiter which is used to track the content types which are considered valid value models for an Attribute.
Bases: philo.models.base.AttributeValue
Stores a python object as a json string.
Bases: philo.models.base.AttributeValue
Stores a generic relationship to an instance of any value content type (as defined by the value_content_type_limiter).
Bases: philo.models.base.AttributeValue
Stores a generic relationship to many instances of any value content type (as defined by the value_content_type_limiter).
An instance of ContentTypeRegistryLimiter which is used to track the content types which can be related to by ForeignKeyValues and ManyToManyValues.
Registers a model as a valid content type for a ForeignKeyValue or ManyToManyValue through the value_content_type_limiter.
Registers a model as a valid content type for a ForeignKeyValue or ManyToManyValue through the value_content_type_limiter.
An abstract class that simplifies access to related attributes. Most models provided by Philo subclass Entity.
If absolute_result is True, returns the object at path (starting at root) or raises an ObjectDoesNotExist exception. Otherwise, returns a tuple containing the deepest object found along path (or root if no deeper object is found) and the remainder of the path after that object as a string (or None if there is no remaining path).
Note
If you are looking for something with an exact path, it is faster to use absolute_result=True, unless the path depth is over ~40, in which case the high cost of the absolute query may make a binary search (i.e. non-absolute) faster.
Note
SQLite allows max of 64 tables in one join. That means the binary search will only work on paths with a max depth of 127 and the absolute fetch will only work to a max depth of (surprise!) 63. Larger depths could be handled, but since the common use case will not have a tree structure that deep, they are not.
Parameters: |
|
---|---|
Returns: | An instance if absolute_result is True or an (instance, remaining_path) tuple otherwise. |
Raises django.core.exceptions.ObjectDoesNotExist: | |
if no object can be found matching the input parameters. |
Bases: philo.models.base.Entity, mptt.models.MPTTModel
An abstract subclass of Entity which represents a tree relationship.
An instance of TreeEntityManager.
Parameters: |
|
---|---|
Returns: | A string representation of an object’s path. |
Parameters: |
|
---|---|
Returns: | A string representation of an object’s path. |
Parameters: |
|
---|---|
Returns: | A string representation of an object’s path. |