get double the property value when using getattr(individual,'propName')

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

get double the property value when using getattr(individual,'propName')

Mutian
Hello, Jiba

here is the test ontology i created with owlready:

with onto:
    class TestClass(Thing): pass

    class testProp(ObjectProperty): pass

    Test1 = TestClass('Test1')
    Test2 = TestClass('Test2')
    Test2.testProp.append(Test1)

when access it in terminal, everything is fine:
    getattr(Test2,'testProp')  #-> [Test1]

but when i try to access it through a web application i made,value is doubled
    getattr(Test2,'testProp')  #-> [Test1,Test1]

the web framework I'm using is Pyramid, owlready2 version 0.9 and python 3.7

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: get double the property value when using getattr(individual,'propName')

Jiba
Administrator
Hello,

Strange problem... Do you loads your ontology? The first value might be present in the file.

For helping debugging, you can:

 * use default_world.graph.dump() to see the entire content of the quadstore, and verify whether the property value is mentioned twice or not.

 * call set_log_level(9) BEFORE defining the property, in order to whether the triple for the property is asserted twice.

Best regards,
Jean-Baptiste Lamy
MCF HDR, Laboratoire LIMICS, Université Paris 13
Reply | Threaded
Open this post in threaded view
|

Re: get double the property value when using getattr(individual,'propName')

Mutian
I moved the ontology.load() line to a seperate file and import the file, the problem is gone.
So, maybe the cause is some mechanism of the web framework I don't quite understand.

Anyway, Thanks for your help