Re: possible bug with autorelationships
Sebastien Bigaret <[email protected]> 21 Sep 2004 12:17:22 +0200
| Newsgroups | gmane.comp.python.modeling |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Sorry for the late answer.
You've found a bug, indeed; however, it's not exactly where we think it
can be at first sight!
The fact is that we do not support one-to-one relationship directly
for the moment being, see here the instructions for a workaround:
http://modeling.sourceforge.net/UserGuide/design-rels.html
The error you get is completely due to the fact that a one-to-one isn't
expected there, but this should be treated by something else than an
assert clause.
I've not look closely yet to what happens when you suppress the BaseType
(hence, suppressing the error as well), but I suspect that the model is
not correct. This needs further investigation, obviously --in any case,
again, the pymodel should be able to report that the one-to-one is not
supported yet.
Thanks for reporting,
-- S=E9bastien.
Lorenzo Gil Sanchez <[email protected]> wrote:
> Hi,
>=20
> 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.
>=20
> I have a Customer entity which is-a Person, which is-a BaseType. This is
> how my PyModel looks like:
>=20
> from Modeling.PyModel import *
>=20
> Entity.defaults['properties'] =3D [
> APrimaryKey('id', isClassProperty=3D0, isRequired=3D1, doc=3D'PK')
> ]
>=20
> _connDict =3D {'database': 'pruebas_modeling.sqlite'}
>=20
> model =3D Model('Pruebas', adaptorName=3D'SQLite', connDict=3D_connDict,
> version=3D'0.1')
>=20
> model.entities =3D [
> Entity('BaseType',
> properties=3D[AFloat('oid', doc=3D'Internal object identifier'=
)]
> ),
>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
> Entity('Person',
> properties=3D[AString('name'),
> AString('surname'),
> ADateTime('birthdate'),
> AInteger('employed', defaultValue=3D1),
> RToOne('husband', destination=3D'Person',
> inverse=3D'wife'),
> RToOne('wife', destination=3D'Person',
> inverse=3D'husband')],
> parent=3D'BaseType',
> ),
> Entity('Customer',
> properties=3D[AFloat('salary')],
> parent=3D'Person',
> ),
> ]
>=20
> model.build()
>=20
> ------------------------------------------------------
>=20
> 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=3Dcheck_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 =3D=3D y
> AssertionError
>=20
>=20
> There are several ways to get rid of the exception:
>=20
> - Remove the Customer entity
> - Make the Person entity don't inherit from BaseType
> - Remove the BaseType entity
>=20
> 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.
>=20
> Thanks
>=20
> Lorenzo Gil Sanchez
-------------------------------------------------------
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