diff --git a/entities.py b/entities.py index 74eb3c3bd18f3df9083706e437d4cde83e125605_ZW50aXRpZXMucHk=..69db5f062634d02963713c7bb4d6411cde9fe68a_ZW50aXRpZXMucHk= 100644 --- a/entities.py +++ b/entities.py @@ -14,6 +14,11 @@ from cubicweb.selectors import implements from cubicweb.entities import AnyEntity, fetch_config + +def subcomments_count(commentable): + return sum([len(commentable.reverse_comments)] + + [subcomments_count(c) for c in commentable.reverse_comments]) + class Comment(TreeMixIn, AnyEntity): """customized class for Comment entities""" __regid__ = 'Comment' @@ -34,10 +39,9 @@ """ return self.root().rest_path(), {} - def subcomments_count(self): - return sum([len(self.reverse_comments)] - + [c.subcomments_count() for c in self.reverse_comments]) + subcomments_count = subcomments_count + # some views potentially needed on web *and* server side (for notification) # so put them here @@ -40,8 +44,7 @@ # some views potentially needed on web *and* server side (for notification) # so put them here - class CommentFullTextView(EntityView): __regid__ = 'fulltext' __select__ = implements('Comment')