Discussion:
[Modeling-users] (more) problems with inheritance
Lorenzo Gil Sanchez
2004-08-17 16:43:04 UTC
Permalink
Hi again :-)

Using the dynamic module (from CVS) I was able to create the Python
classes of my model, which uses inheritance:

My model has two entities: Person and Customer, which inherits from
Person.

My problem now is related to fetches. I have two instances on my
EditingContext: a person and a customer:

ec = EditingContext()
p = Person()
p.setName('Erny')
ec.insert(p)
print p

c = Customer()
c.setName('Lorenzo')
c.setPhone('93923924')
print c

Now, how do I get all the person in my editing context?

query = ec.fetch('Person', isDeep=1)
print len(query)
1

As you can see I'm getting one object when I should been getting two
since the Customer is-a Person

Am I doing something wrong or I just hit a bug?

I'll attach the whole code so everybody can test it.

Regards

Lorenzo
Sebastien Bigaret
2004-08-17 20:14:05 UTC
Permalink
You should get both objects with isDeep=1, right...
but before that, you need to 'ec.insert(c)' as well ;)

-- Sébastien.
Post by Lorenzo Gil Sanchez
Hi again :-)
Using the dynamic module (from CVS) I was able to create the
My model has two entities: Person and Customer, which
inherits from Person.
My problem now is related to fetches. I have two instances on my
ec = EditingContext()
p = Person()
p.setName('Erny')
ec.insert(p)
print p
c = Customer()
c.setName('Lorenzo')
c.setPhone('93923924')
print c
Now, how do I get all the person in my editing context?
query = ec.fetch('Person', isDeep=1)
print len(query)
1
As you can see I'm getting one object when I should been
getting two since the Customer is-a Person
Am I doing something wrong or I just hit a bug?
I'll attach the whole code so everybody can test it.
Regards
Lorenzo
Lorenzo Gil Sanchez
2004-08-18 06:44:06 UTC
Permalink
Sorry about this. Obviously I forgot to insert it on the EditingContext
as Mario also reminded me. Stupid mistake.

Thanks

Lorenzo
Post by Sebastien Bigaret
You should get both objects with isDeep=1, right...
but before that, you need to 'ec.insert(c)' as well ;)
-- Sébastien.
Post by Lorenzo Gil Sanchez
Hi again :-)
Using the dynamic module (from CVS) I was able to create the
My model has two entities: Person and Customer, which
inherits from Person.
My problem now is related to fetches. I have two instances on my
ec = EditingContext()
p = Person()
p.setName('Erny')
ec.insert(p)
print p
c = Customer()
c.setName('Lorenzo')
c.setPhone('93923924')
print c
Now, how do I get all the person in my editing context?
query = ec.fetch('Person', isDeep=1)
print len(query)
1
As you can see I'm getting one object when I should been
getting two since the Customer is-a Person
Am I doing something wrong or I just hit a bug?
I'll attach the whole code so everybody can test it.
Regards
Lorenzo
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Modeling-users mailing list
https://lists.sourceforge.net/lists/listinfo/modeling-users
Mario Ruggier
2004-08-17 20:34:12 UTC
Permalink
Post by Lorenzo Gil Sanchez
c = Customer()
c.setName('Lorenzo')
c.setPhone('93923924')
print c
You are forgetting to ec.insert(c)...

For your previous mail about inheritance problem, wait until Seb is
back to confirm whether it is actually a bug or not...

mario
Mario Ruggier
2004-08-17 21:04:23 UTC
Permalink
Post by Lorenzo Gil Sanchez
c = Customer()
c.setName('Lorenzo')
c.setPhone('93923924')
print c
You are forgetting to ec.insert(c)...

For your previous mail about inheritance problem, wait until Seb is
back to confirm whether it is actually a bug or not...

mario
Loading...