| | 398 | # Handle any ancestors (for the model-inheritance case). We do this by |
|---|
| | 399 | # traversing to the most remote parent classes -- those with no parents |
|---|
| | 400 | # themselves -- and then adding those instances to the collection. That |
|---|
| | 401 | # will include all the child instances down to "self". |
|---|
| | 402 | parent_stack = self._meta.parents.values() |
|---|
| | 403 | while parent_stack: |
|---|
| | 404 | link = parent_stack.pop() |
|---|
| | 405 | parent_obj = getattr(self, link.name) |
|---|
| | 406 | if parent_obj._meta.parents: |
|---|
| | 407 | parent_stack.extend(parent_obj._meta.parents.values()) |
|---|
| | 408 | continue |
|---|
| | 409 | # At this point, parent_obj is base class (no ancestor models). So |
|---|
| | 410 | # delete it and all its descendents. |
|---|
| | 411 | parent_obj._collect_sub_objects(seen_objs) |
|---|
| | 412 | |
|---|