Hello!

I'm using the "nested set" abstraction to store some tree data in a
Django model. So the model class looks like

class TreeNode(models.Model):
    value = models.CharField(maxlength=10)
    leftVisit = models.IntegerField(primary_key=True)
    rightVisit = models.IntegerField(db_index=True)

    def insertChild(self, **kwargs):
        """Add a child node to this node."""
        cursor = conection.cursor()
        # do some magic, potentially updating many objects using the
cursor
        ...

        return child

    def getPathToRoot(self):
        """Returns the path of nodes to the root node"""
        return AltStep.objects.filter(leftVisit__lt=self.leftVisit,
rightVisit__gt=self.rightVisit)

This all works fine, but, in this abstraction, an insert into the tree
updates everything to the "right" of it. This means that any python
objects I have in memory for this model are now dirty and need to be
updated from the database. Is there a way I can ask objects to refresh
themselves from the database?

Thanks,
Lars


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to