Re: (more) problems with inheritance

Sebastien Bigaret <[email protected]> Tue, 17 Aug 2004 23:10:58 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
	
  You should get both objects with isDeep=1, right...
but before that, you need to 'ec.insert(c)' as well ;)

-- Sébastien.


Lorenzo Gil Sanchez wrote:
> 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
> 



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