Hi,

We have a use case where we would like to have "incremental updates"
to existing session objects (ie. populate_existing()-type behaviour
where existing object's lazy-loaded attributes are not reset by
subsequent populate_existing queries).

We have come up with a solution by implementing a subclassed
LazyLoader strategy that returns a No-op function in the
"create_row_processor" (basically skipping line 474 in
sqlalchemy.orm.strategies in version 0.5.8). Is this a safe place to
put this functionality? Note that this session is never used for
flushing, it is used as a read-only caching session.


from sqlalchemy.orm.strategies import LazyLoader
class IncrementalLazyLoader(LazyLoader):

    def create_row_processor(self, *args, **kwargs):
        if self.is_class_level:
            def new_execute(state, dict_, row, **flags):
                pass
            return (new_execute, None)
        else:
            return super(IncrementalLazyLoader,
self).create_row_processor(*args, **kwargs)


This special strategy is used on lazy mapped properties by passing a
"strategy_class" to the relation() call.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to