On Dec 17, 2011, at 12:22 PM, Kent wrote:
> Yeah, the approach that iterates over the properties you don't pass is the
> one I wrote a bit back, even called it .lazyload_except(). But that's what I
> referred to as the "
>
> less than adequate solution". I want it to be much easier to use so I'm not
> requiring the user to specify the joinedloads twice (once for the joinedload
> and once for the .lazyload_except(). So i'm after your second alternative.
>
> _get_context_strategy() looks promising to me. By default, if a relationship
> (or column, in the case of ticket #1418) isn't specified in the
> context.attributes as a 'loaderstrategy', then self. strategy is returned.
>
> def _get_context_strategy(self, context, path):
> cls = context.attributes.get(('loaderstrategy',
> _reduce_path(path)), None)
> if cls:
> try:
> return self.__all_strategies[cls]
> except KeyError:
> return self.__init_strategy(cls)
> else:
> return self.strategy
>
>
> I can reference the query from the context and then change the default
> behavior to return a self.__init_strategy(LazyLoader) if the query has been
> told to lazy load all others?
if you want a Query to lazyload everything by default then the
_get_context_strategy(), or some system around it (I don't have the time to
look at the source right now) needs to be changed to recognize some kind of
"wildcard" - right now a MapperOption puts a key that is along the lines of
(MyClass.somerelation, "eager") into attributes - so it would be like ("*",
"lazy"). This is not how it actually looks but the idea would be along those
lines.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.