X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/946f2dc5728e293dd7fc55bac7a8cf8d3dcc5722..5da36a259abcc9fb76b736fc360560f0ff931640:/philo/models/base.py diff --git a/philo/models/base.py b/philo/models/base.py index f9c22f9..2f798ae 100644 --- a/philo/models/base.py +++ b/philo/models/base.py @@ -16,7 +16,7 @@ from philo.utils.entities import AttributeMapper, TreeAttributeMapper from philo.validators import json_validator -__all__ = ('Tag', 'value_content_type_limiter', 'register_value_model', 'unregister_value_model', 'JSONValue', 'ForeignKeyValue', 'ManyToManyValue', 'Attribute', 'Entity', 'TreeEntity') +__all__ = ('Tag', 'value_content_type_limiter', 'register_value_model', 'unregister_value_model', 'JSONValue', 'ForeignKeyValue', 'ManyToManyValue', 'Attribute', 'Entity', 'TreeEntity', 'SlugTreeEntity') class Tag(models.Model): @@ -319,7 +319,12 @@ class Entity(models.Model): """ return mapper(self) - attributes = property(get_attribute_mapper) + + @property + def attributes(self): + if not hasattr(self, '_attributes'): + self._attributes = self.get_attribute_mapper() + return self._attributes class Meta: abstract = True @@ -500,7 +505,6 @@ class TreeEntity(Entity, MPTTModel): else: mapper = AttributeMapper return super(TreeEntity, self).get_attribute_mapper(mapper) - attributes = property(get_attribute_mapper) def __unicode__(self): return self.path