1
0
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:
Rob van der Linde 2024-02-21 14:11:52 +13:00 committed by Andrew Bartlett
parent 5870035486
commit ccce7e7c03

View File

@ -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