right_ancestry = []
for comment in comments:
# If this comment is a child of the last, bump the nesting level
if last_comment and comment.left < last_comment.right:
right_ancestry = []
for comment in comments:
# If this comment is a child of the last, bump the nesting level
if last_comment and comment.left < last_comment.right:
# broken out of, back out a level
for i in xrange(len(right_ancestry) - 1, -1, -1):
if comment.left > right_ancestry[i].right:
# broken out of, back out a level
for i in xrange(len(right_ancestry) - 1, -1, -1):
if comment.left > right_ancestry[i].right:
- time = Field(DateTime, default=datetime.datetime.now)
- text = Field(Unicode(65536))
+ time = Field(DateTime, default=datetime.datetime.now, required=True)
+ text = Field(Unicode(65536), required=True)
# Comments are a tree, and are stored as a nested set, because:
# - It's easy to get a subtree with a single query.
# Comments are a tree, and are stored as a nested set, because:
# - It's easy to get a subtree with a single query.
# The only real disadvantage is that adding a comment requires a quick
# update of all the following comments (in post-order), but that's rare
# enough that it shouldn't be a problem.
# The only real disadvantage is that adding a comment requires a quick
# update of all the following comments (in post-order), but that's rare
# enough that it shouldn't be a problem.
- left = Field(Integer, index=True)
- right = Field(Integer)
+ left = Field(Integer, index=True, required=True)
+ right = Field(Integer, required=True)
- discussion = ManyToOne('Discussion')
- user = ManyToOne('User')
+ discussion = ManyToOne('Discussion', required=True)
+ user = ManyToOne('User', required=True)
def __init__(self, parent=None, **kwargs):
"""Constructor override to set left/right correctly on a new comment.
def __init__(self, parent=None, **kwargs):
"""Constructor override to set left/right correctly on a new comment.