On Dec 17, 2011, at 3:04 PM, Kent wrote:

> Nevermind... got it.  Thanks for your help!
> 
> I couldn't really tell whether you'd be interested adding this feature to the 
> product?  I didn't especially like that I needed to override
> RelationshipProperty._get_context_strategy() without being able to invoke 
> super()._get_context_strategy() because my code needed to be mid method.
> 
> You might have a better way:
> 
> As a side note, interfaces.py StrategizedProperty's has copied code that 
> seems redundant to me:
> 
> 
>    def _get_context_strategy(self, context, reduced_path):
>        key = ('loaderstrategy', reduced_path)
>        if key in context.attributes:
>            cls = context.attributes[key]
>            try:
>                return self._strategies[cls]
>            except KeyError:
>                return self.__init_strategy(cls)
>        else:
>            return self.strategy
> 
>    def _get_strategy(self, cls):
>        try:
>            return self._strategies[cls]
>        except KeyError:
>            return self.__init_strategy(cls)
> 
> 
> This can be simplified to:
> 
>    def _get_context_strategy(self, context, reduced_path):
>        key = ('loaderstrategy', reduced_path)
>        if key in context.attributes:
>            self._get_strategy(context.attributes[key])     # <=========
>        else:
>            return self.strategy

Yeah, that code is actually inlined as it's prominent in profiling against 
tests that do lots of queries.   These days we're a little less manic about 
single method inlines like this and it's possible this inlining is from pre-0.5 
versions when we might have been calling it on each result row so perhaps it 
can be revisited.


-- 
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.

Reply via email to