I have run into this a lot in couchdbkit - as far as I can tell the child objects under a couchdbkit Document object have no reference back to the parent. I hope I am wrong though:
class Child(DocumentSchema):
name = StringProperty()
def parent(self):
# How do I get a reference to the parent object here?
if self.parent.something:
print 'yes'
else:
print 'no'
class Parent(Document):
something = BooleanProperty()
children = SchemaListProperty(Child)
doc = Parent.get('someid')
for c in doc.children:
c.parent()
Right now what I have been doing is passing around the parent object, but I don't like this approach.
I just chatted with the author of couchdbkit and apparently what I am trying to do is not supported now.