Dynamic loaders

1 view
Skip to first unread message

Ben Bangert

unread,
Nov 4, 2007, 6:36:42 PM11/4/07
to SQLElixir
How do I indicate that instead of a relation, Elixir should build a
relation as a dynamic loader?
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_largecollections_dynamic

Cheers,
Ben

Gaetan de Menten

unread,
Nov 5, 2007, 3:13:58 AM11/5/07
to sqle...@googlegroups.com

There is no explicit support for those at the moment. Does the
lazy="dynamic" way works for normal relations (in addition to with
backrefs)?

If not, you can define one by using the generic "GenericProperty" or
the corresponding "has_property" statement. If needed, implementing
specific support for that wouldn't be hard: we could simply add a new
kwarg to all relationships. "dynamic" comes to mind.

--
Gaëtan de Menten
http://openhex.org

Ben Bangert

unread,
Nov 5, 2007, 7:28:17 PM11/5/07
to SQLElixir
On Nov 5, 12:13 am, "Gaetan de Menten" <gdemen...@gmail.com> wrote:
> There is no explicit support for those at the moment. Does the
> lazy="dynamic" way works for normal relations (in addition to with
> backrefs)?

Nope, instead of this being defined by relation(....), its defined as
dynamic_loader(...). It's totally different from lazy="dynamic" afaik,
which is merely a relation option.

> If not, you can define one by using the generic "GenericProperty" or
> the corresponding "has_property" statement. If needed, implementing
> specific support for that wouldn't be hard: we could simply add a new
> kwarg to all relationships. "dynamic" comes to mind.

I'm not sure I understand what this means, nor can I find it in the
docs. How does Property map to an SA relation?

To be more flexible, perhaps an option can be used where you can pass
in an alternate relation loader than sqlalchemy.orm.relation, ie,
you'd explicitly pass it the sqlalchemy.orm.dynamic_loader function
and Elixir would use that. This way if SQLAlchemy add's new relation
loaders, they can easily be used.

Cheers,
Ben

Reply all
Reply to author
Forward
0 new messages