Closed berycz closed 1 year ago
hmm, is it possible the dir
changed the order of links in test_edit_table
? 🤔
yeah, dir()
- The resulting list is sorted alphabetically
:(
I havent thought about it, then this PR is useless and can be closed
sorry for bothering you, I forgot to test it localy first
Inheritance of the meta class? So like
class BaseMeta:
foo = 1
class A(Table):
class Meta(BaseMeta):
pass
?
yea, that's what I was trying to do, but thanks to current for key in class_.Meta.__dict__:
the foo = 1
gets lost, because Meta.__dict__
does not contain properties of BaseMeta
there might be a way to go through class_.Meta.mro()
and read from all of their .__dict__
, not sure if it isnt too complicated or slow?
tests ok, but I havent checked if it works :D maybe a new test would be needed too but the question also is, would you agree with such a change...?
jlubcke says "helt rätt!" (absolutely correct) :P
I'm even a bit happy :)
nice, thanks!
btw there I have value = getattr(class_.Meta, key)
which might also be value = getattr(meta_class_, key)
, but I didn't see a reason for that, because in the end it's gonna be the same value :)
this small change allows Meta mixins, I talked about this on discord in #beginner (2023-08-04)
dir
might be a bit slower than__dict__
since it bubbles though mro, but I don't think it runs often enough to be even noticeableMy usecase is: I have 5 different tables and 6 different forms for the same model based on user "role", they differ too much to have one class but still share some properties. I use inheritance now, but I think Meta mixins would make it much cleaner
@jlubcke should check this for potential problems