You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have implemented some sort of foreign keys automatic fetching. For this I just created custom Property, that automatically returns related document from database when such property is get. But couchdbkit also always calls get on set operation.
Here is example:
I try to set a value to docref property:
doc.docref = special_docref_object
CouchDbKit uses hasattr(self, key) in setattr, what causes get to be called:
couchdbkit/schema/base.py(182)__setattr__()
--> 182 if not hasattr( self, key ) ...
Now I get unwanted behaviour - database hit, because get is called, but should not be:
myapp.py(169)__get__()
--> 169 db.get(value)
Maybe
hasattr(self, key)
can be replaces with:
hasattr(self._properties, key)
?
The text was updated successfully, but these errors were encountered:
getattr doesn't only looks in self.properties though. Maybe this can be changed at this point. I syour property code open somewhere so I can eventually try it?
But for now, I did a workaround, and made referenced node loading from database only through ref attribute, direct call just returns lazy reference object. So now it solves problem for me.
I have implemented some sort of foreign keys automatic fetching. For this I just created custom Property, that automatically returns related document from database when such property is get. But couchdbkit also always calls get on set operation.
Here is example:
I try to set a value to docref property:
CouchDbKit uses hasattr(self, key) in setattr, what causes get to be called:
Now I get unwanted behaviour - database hit, because get is called, but should not be:
Maybe
can be replaces with:
?
The text was updated successfully, but these errors were encountered: