from django.contrib.contenttypes import generic
from django.utils import simplejson as json
from django.core.exceptions import ObjectDoesNotExist
+from philo.exceptions import AncestorDoesNotExist
from philo.utils import ContentTypeRegistryLimiter
from philo.signals import entity_class_prepared
from UserDict import DictMixin
class Meta:
app_label = 'philo'
+ unique_together = ('key', 'entity_content_type', 'entity_object_id')
value_content_type_limiter = ContentTypeRegistryLimiter()
class Meta:
app_label = 'philo'
+ unique_together = ('key', 'entity_content_type', 'entity_object_id')
class QuerySetMapper(object, DictMixin):
class TreeModel(models.Model):
objects = TreeManager()
parent = models.ForeignKey('self', related_name='children', null=True, blank=True)
- slug = models.SlugField()
+ slug = models.SlugField(max_length=255)
def has_ancestor(self, ancestor):
parent = self
return False
def get_path(self, root=None, pathsep='/', field='slug'):
- if root is not None and self.has_ancestor(root):
+ if root is not None:
+ if not self.has_ancestor(root):
+ raise AncestorDoesNotExist(root)
path = ''
parent = self
while parent and parent != root:
abstract = True
-class TreeEntity(TreeModel, Entity):
+class TreeEntity(Entity, TreeModel):
@property
def attributes(self):
if self.parent: