Re: using axiom.dependency for powerups in queries

Tristan Seligmann <[email protected]> Tue, 11 Mar 2008 14:46:45 +0200
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
--===============1358155022==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX"
Content-Disposition: inline


--huq684BweRXVnRxX
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Robert Gravina <[email protected]> [2008-03-11 19:33:05 +0900]:

> Great, thanks! That works, but I'm really thinking of the case where I'd=
=20
> be using store.query to return a list of people... I just used findFirst=
=20
> in this example because there was only one. E.g., for many Person:
>
>     for person in s.query(Contractor, Contractor.rate =3D=3D Decimal("40"=
)):
>         p =3D dependency.installedOn(person)
>
> works, as does:
>
>     people =3D [dependency.installedOn(person) for person in s.query=20
> (Contractor, Contractor.rate =3D=3D Decimal("40"))]
>
> but is there a way to get the query to return Person instead of =20
> Contractor?

Theoretically you could write a query that joins on Person, Contractor,
and _DependencyConnector; but using private names is a bad idea, the
query probably wouldn't be much more efficient, and it would be a lot
harder to understand.

Perhaps I should add that using powerups for your Contractor / Person
relationship seems quite artificial; I would just add an attribute to
Contractor:

    person =3D reference(reftype=3DContractor)

and then write queries like:

s.query(Person, AND(Person.storeID =3D=3D Contractor.person,
                    Contractor.rate =3D=3D Decimal("40")))

I think the main uses of powerups are where the powerup interface is the
primary concern; either for adaptation of an item, or because you have
multiple items of different types, but providing the same interface, and
you want to treat them as a group.
--=20
mithrandi, i Ainil en-Balandor, a faer Ambar

--huq684BweRXVnRxX
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.8 (GNU/Linux)

iEYEARECAAYFAkfWfzQACgkQpNuXDQIV94rmzgCbBjQwVFKLfCyXyq/3IikRmd1I
/2sAn1Pz5PEucrAiRjkCPj8ehErS43iO
=GmoR
-----END PGP SIGNATURE-----

--huq684BweRXVnRxX--


--===============1358155022==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline