pwin / owlready2

GNU Lesser General Public License v3.0
132 stars 22 forks source link

inherit ontology and python class #18

Open c-mellueh opened 2 years ago

c-mellueh commented 2 years ago

Hi, i'm trying to let a ontology class inherit from a standard python class and also the Thing class. I want this to work, because the python class stores some function i use in a lot of other classes and i dont want to copy them all the time. If i transform my python class into an ontology class, almost every class is connected with them (which doesnt make sems imo).

I'm trying something like this:

class MvdXml(Thing, IdentityObject):

    namespace = onto

    def __init__(self, file: str = None, doc: str = None, validation=None) -> etree._Element:
        super().__init__()

where Thing is the ontology class and IdentityObject is the python class.

My errormessage is

line 162, in _add_is_a_triple
    Class.namespace.ontology._add_obj_triple_spo(Class.storid, Class._rdfs_is_a, base.storid)
AttributeError: type object 'IdentityObject' has no attribute 'storid'

so i guess owlready2 wants the pythonclass to also be an ontologyclass. Is there a workaround?