This project moves so fast.
I guess it's time to reread the documentation. Again.

Knowing how great this project is, it was silly of me not to
expect SQLAlchemy ho have such functionality built in into
the public interface: I was kinda expecting to play with the
object state or who knows what.

On Jan 21, 10:35 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> the session.merge() method is provided with a flag dont_load=True to  
> assist in common caching scenarios.  it copies the state of a cached  
> object into a given session so that you get the benefits of globally  
> cached state combined with no data shared between sessions.
>
> some examples of moderately-to-completely transparent caches that  
> build into Query are in the examples directory with the distribution  
> under examples/query_caching.  they might give you some ideas.
>
> On Jan 21, 2009, at 3:51 PM, qvx wrote:
>
>
>
> > I have a web application which is accessed from different sub-domains.
> > Each sub-domain corresponds to one row/object in "installation" table.
> > I am fetching this one row/object on every request which is
> > unnecessary.
> > My question is: how can I fetch this object only once and somehow
> > stuff it inside a session on each request, from memory.
>
> > Currently I'm doing this:
>
> > def web_method():
> >    # fetch every time:
> >    subdomain = get_subdomain()
> >    installation = session.query(Installation).filter_by
> > (subdomain=subdomain).one()
>
> >    # use installation as filter
> >    session.query(SomeOb).filter_by(installation=installation).all()
>
> > I want this:
>
> > def web_method2():
> >    # get from cache
> >    installation_data = get_subdomain_data()
> >    installation = Installation(**installation_data)
>
> >    # somehow add installation to session so that it appears
> >    # as if it has just been fetched from db
> >    ???
>
> >    # this must work
> >    session.query(SomeOb).filter_by(installation=installation).all()
>
> >    # this must also work
> >    # select child/parent objects from corresponding relations
> >    len(installation.related_child_object_list)
> >    installation.related_parent_object
>
> > Thanks,
> > Tvrtko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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