tuomur / python-odata

A simple library for read/write access to OData services
MIT License
79 stars 59 forks source link

the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases #51

Open floris-b opened 3 years ago

floris-b commented 3 years ago

What could be the cause of the error message when loading metadata?

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

floris-b commented 3 years ago

It goes wrong on the second entity set is load:

      <EntityType Name="Right_DataRight"
                  BaseType="OData.Right">
        <Property Name="Read"
                  Type="Edm.Boolean" />
        <Property Name="Delete"
                  Type="Edm.Boolean" />
        <Property Name="Create"
                  Type="Edm.Boolean" />
        <Property Name="Update"
                  Type="Edm.Boolean" />
      </EntityType>

      <EntityType Name="EntityType"
                  BaseType="OData.Entity">
        <Property Name="HasInvolved"
                  Type="Edm.Boolean" />
        <Property Name="IsNameHiddenForUser"
                  Type="Edm.Boolean" />
        <Property Name="HasProducts"
                  Type="Edm.Boolean" />
        <Property Name="AllowNoteOrAttachmentDuringConstruction"
                  Type="Edm.Boolean" />
        <Property Name="IsInUserPack"
                  Type="Edm.Boolean" />
        <Property Name="IsOverridable"
                  Type="Edm.Boolean" />
        <Property Name="IsMetadata"
                  Type="Edm.Boolean" />
        <Property Name="Metadata"
                  Type="Edm.String" />
        <Property Name="Name"
                  Type="Edm.String" />
        <NavigationProperty Name="DataRight"
                            Type="Collection(OData.Right_DataRight)" />

        <NavigationProperty Name="DataRight"
                            Type="Collection(OData.Right_DataRight)" />

        <EntitySet Name="OData.Right_DataRight"
                   EntityType="OData.Right.DataRight" />

      </EntityType>

      <EntityType Name="Right"
                  BaseType="OData.Entity">
        <NavigationProperty Name="Role"
                            Type="OData.RightsProfile" />
      </EntityType>
2021-02-09 08:20:47,063 INFO 239:metadata.py(1525) - Load {'name': 'OData.LayoutTemplate', 'type': 'OData.LayoutTemplate', 'schema': {'name': 'LayoutTemplate', 'type': 'OData.LayoutTemplate', 'properties': [{'name': 'Specification', 'type': 'Edm.String', 'is_primary_key': False, 'is_collection': False, 'is_computed_value': False}], 'navigation_properties': [], 'base_type': 'OData.Entity'}} entity set
2021-02-09 08:20:47,070 INFO 239:metadata.py(1525) - Load {'name': 'OData.Right_DataRight', 'type': 'OData.Right.DataRight', 'schema': None} entity set

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-45-d43293df7892> in <module>
----> 1 Service = ODataService(SERVICE_URL,reflect_entities=True,session=oauth)

~/work/odata/service.py in __init__(self, url, base, reflect_entities, session, auth)
    140 
    141         if reflect_entities:
--> 142             _, self.entities, self.types = self.metadata.get_entity_sets(base=self.Entity)
    143 
    144         self.Entity.__odata_url_base__ = url

~/work/odata/metadata.py in get_entity_sets(self, base)
    241             set_name = entity_set.get('name')
    242             is_singleton = entity_set.get('singleton', False)
--> 243             set_class = type('EntitySet' + set_name, (entity_class,), dict(__odata_collection__=set_name, __odata_singleton__=is_singleton))
    244             sets[set_name] = set_class
    245 

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
floris-b commented 3 years ago

where does the OData.LayoutTemplate come from? I do not see any mention of it in the metadata