On Aug 24, 2011, at 11:12 PM, Ahmed wrote:
> It seems I am very close to an answer by Michael Bayer demonstrated in
> that thread:
> http://groups.google.com/group/sqlalchemy/browse_thread/thread/2f60ee62e1ed6a0a
>
> I changed the strategies on the class mapper RelationshipProperties as
> follows:
>
> def make_dynamic(sqlalchemy_class):
> mapper = class_mapper(sqlalchemy_class)
>
> for prop in mapper.iterate_properties:
> if isinstance(prop, RelationshipProperty):
> prop.strategy_class = strategies.factory('dynamic')
> interfaces.StrategizedProperty.do_init(prop)
>
> changing the strategy to subquery seems to be working fine (sql
> queries run in console on instance loading), however changing that to
> 'dynamic' does not get the same effect and I still have normal
> instrumented lists instead of appender queries.
>
> Any clues? I appreciate your help.
from the original question it appears you're looking to do a with_parent kind
of query... if you have MyClass->MyRelated ...
class MyClass(Base):
...
stuff = relationship("MyRelated")
@property
def dynamic_stuff(self):
return object_session(self).query(MyRelated).with_parent(self, "stuff")
no tinkering with internals needed in that case...
>
> Cheers,
> Ahmed
>
>
> On Aug 22, 5:04 pm, Ahmed <[email protected]> wrote:
>> Hello,
>> I wonder if there is a possibility given an object instance (say with
>> an InstrumentedList of a relationship attribute).. to get a
>> corresponding dynamic query of this same InstrumentedList (the List
>> was configured in the declarative class with a lazy loader and not a
>> dynamic loader)??
>>
>> Cheers
>
> --
> 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.
>
--
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.