possible bug with autorelationships

Lorenzo Gil Sanchez <[email protected]> Fri, 17 Sep 2004 14:19:05 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
--=-bdJ5YPMlNXO+aDHjI+GJ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

I have a Person entity and I'm trying to define a relationship between
two persons. Something like the husband/wife relationship. So far it
works, the problem is when other classes appear in the inheritance tree.

I have a Customer entity which is-a Person, which is-a BaseType. This is
how my PyModel looks like:

from Modeling.PyModel import *

Entity.defaults['properties'] = [
    APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK')
    ]

_connDict = {'database': 'pruebas_modeling.sqlite'}

model = Model('Pruebas', adaptorName='SQLite', connDict=_connDict,
              version='0.1')

model.entities = [
    Entity('BaseType',
           properties=[AFloat('oid', doc='Internal object identifier')]
           ),
                       
    Entity('Person',
           properties=[AString('name'),
                       AString('surname'),
                       ADateTime('birthdate'),
                       AInteger('employed', defaultValue=1),
                       RToOne('husband', destination='Person',
inverse='wife'),
                       RToOne('wife', destination='Person',
inverse='husband')],
           parent='BaseType',
           ),
    Entity('Customer',
           properties=[AFloat('salary')],
           parent='Person',
           ),
    ]

model.build()

------------------------------------------------------

If I run that code I get this exception:
Traceback (most recent call last):
  File "prueba_autorrelacion.py", line 32, in ?
    model.build()
  File "/opt/lib/python2.3/site-packages/Modeling/PyModel.py", line 228,
in build
    entity.build_toOne_relationships(self)
  File "/opt/lib/python2.3/site-packages/Modeling/PyModel.py", line 446,
in build_toOne_relationships
    prop.build(model, self)
  File "/opt/lib/python2.3/site-packages/Modeling/PyModel.py", line 701,
in build
    entity.forward_rel_info(self, model)
  File "/opt/lib/python2.3/site-packages/Modeling/PyModel.py", line 437,
in forward_rel_info
    rel.dst,invr.src=check_or_make_equal(rel.dst,invr.src)
  File "/opt/lib/python2.3/site-packages/Modeling/PyModel.py", line 421,
in check_or_make_equal
    assert x == y
AssertionError


There are several ways to get rid of the exception:

- Remove the Customer entity
- Make the Person entity don't inherit from BaseType
- Remove the BaseType entity

Obviously none of those is what I want so I wonder if anyone in the list
knows why my relations are messing the inheritance or viceversa.

Thanks

Lorenzo Gil Sanchez


--=-bdJ5YPMlNXO+aDHjI+GJ
Content-Disposition: attachment; filename=prueba_autorrelacion.py
Content-Type: application/x-python; name=prueba_autorrelacion.py
Content-Transfer-Encoding: 7bit

from Modeling.PyModel import *

Entity.defaults['properties'] = [
    APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK')
    ]

_connDict = {'database': 'pruebas_modeling.sqlite'}

model = Model('Pruebas', adaptorName='SQLite', connDict=_connDict,
              version='0.1')

model.entities = [
    Entity('BaseType',
           properties=[AFloat('oid', doc='Internal object identifier')]
           ),
                       
    Entity('Person',
           properties=[AString('name'),
                       AString('surname'),
                       ADateTime('birthdate'),
                       AInteger('employed', defaultValue=1),
                       RToOne('husband', destination='Person', inverse='wife'),
                       RToOne('wife', destination='Person', inverse='husband')],
           parent='BaseType',
           ),
    Entity('Customer',
           properties=[AFloat('salary')],
           parent='Person',
           ),
    ]

model.build()

--=-bdJ5YPMlNXO+aDHjI+GJ--



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php