Closed Jaymon closed 8 years ago
This makes sense, the problem was the value caching of the decorator was causing the Foo.query property method to be replaced with the actual FooQuery class, then Bar's query_class
property method would never be fired because it was relying on Foo's query_class
property method, which had been replaced by an actual class object.
So
q = Bar.query
q = Foo.query
print q.__name__
Would do the same thing, just in the opposite direction. I've fixed this "bug" by making query_class
have to be explicitly set on the class, while that does involve more work on the part of the developer, it makes the whole process more explicit and self documenting than the current magicalness auto-discovery mechanism that involves too much understanding of the internals of Prom, which is better in the long run for code bases that have more than just me maintaining them.
Setup some classes like this:
then do this:
It won't be
BarQuery
as expected, butFooQuery
. This is because the magical-ness is using the class decorator but that makes it more static instead of class, so Foo setting it makes Bar set it also.I think a fix to this might be to figure out a way to use
@classmethod
which might fix this? I haven't done any research and it might not be possible. If it isn't going that route, then you could make an internal dict that sets things up via class name.