Re: problems with inheritance

Mario Ruggier <[email protected]> Wed, 18 Aug 2004 14:54:41 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
On Aug 18, 2004, at 11:37 AM, Lorenzo Gil Sanchez wrote:
> El mar, 17-08-2004 a las 23:08, [email protected] escribió:
>>
>>   I think that the pb. here is that the root package, named
>> after the model's package nale (here: 'Person' AFAIK) isn't
>> in the python path.
>>
>>   Could you check whether you get the same error with
>> /home/lgs/proyectos/pruebas-modeling/
>> in your PYTHONPATH (before '.', in case you have in the py-path),
>> and report back?  Thanks.
>
> I still get the same error:
>
> [lgs@localhost pruebas-modeling]$ export
> PYTHONPATH=.:/opt/lib/python2.3/site-packages/
>
> [lgs@localhost pruebas-modeling]$ python model_person.py
> Traceback (most recent call last):
>   File "model_person.py", line 33, in ?
>     from Person.Customer import Customer
>   File "/home/lgs/proyectos/pruebas-modeling/Person/Customer.py", line
> 2, in ?
>     from MDL.Customer import Customer as MDL_Customer_Customer
>   File "/home/lgs/proyectos/pruebas-modeling/Person/MDL/Customer.py",
> line 5, in ?
>     from Person.Person import Person
> ImportError: No module named Person

It may well be a bug... from what I can understand there seems to be a 
name-clash problem between the package and the contained modules... if 
you modify your package name (that, if not specified, is taken from the 
model name) to something else, e.g. PymPerson, and then adjust your 
code as follows:

     import sys
     sys.path.insert(0,'.') # if running in dir containing the generated 
PymPerson package...
     print sys.path

     from Modeling.EditingContext import EditingContext
     from PymPerson.Person import Person
     from PymPerson.Customer import Customer

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

     c = Customer()
     c.setName('Lorenzo')
     c.setPhone('93923924')
     ec.insert(c)

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

then, it works as expected... Sebastien, can you can you confirm when 
you get around to it whether this is actually a bug?

mario



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