mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
netcmd: models: ModelMeta needs to also set fields and meta if class is Model
This is needed for polymorphic query, if querying from the Base model, which was not previously a feature. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
5870035486
commit
ccce7e7c03
@ -39,11 +39,11 @@ class ModelMeta(type):
|
||||
|
||||
def __new__(mcls, name, bases, namespace, **kwargs):
|
||||
cls = super().__new__(mcls, name, bases, namespace, **kwargs)
|
||||
cls.fields = dict(inspect.getmembers(cls, lambda f: isinstance(f, Field)))
|
||||
cls.meta = mcls
|
||||
object_class = cls.get_object_class()
|
||||
|
||||
if cls.__name__ != "Model":
|
||||
cls.fields = dict(inspect.getmembers(cls, lambda f: isinstance(f, Field)))
|
||||
cls.meta = mcls
|
||||
MODELS[object_class] = cls
|
||||
|
||||
return cls
|
||||
|
Loading…
Reference in New Issue
Block a user