So how do you scale/split your application across multiple data accessing servers (short of writing an application server)?
Calling objectstore.clear() everywhere? Quoting Michael Bayer <[EMAIL PROTECTED]>: > theres no caching in SQLAlchemy. theres an identity map which has > some of the same effects as a cache. basically, if you have already > loaded your object into the current session, thats it. if you load > it again, its going to use the same one you have, unless you clear > the session, or refresh/expire the object. SA is not going to make a > random guess as to what objects you want refreshed and which ones you > are expecting to stay linked to the current editing session, which > changes you want to keep and which ones youd like to discard. > > consider this scenario: you load object A and object B into the > current session. objects A and B have state information that is > highly interdependent. you then make changes on B which depend > highly on the current state of A. Then some functions are called to > do some not totally related tasks. As a matter of course, within > those function calls some other part of the application makes a > select statement which also requests "A", which has now been modified > in the database by another process. > > returning from the function, A has been magically updated by an > unknown actor, and B is now in an invalid state against the new > version of A. the application breaks. > > the point of the identity map is to prevent the above scenario, and > the myriad of variations on it, from occurring. you are assured that > every object, once loaded into the session, will not change > unexpectedly without your say-so, and because their identity is > assured, all changes made to that object identity are reflected > consistently throughout the editing session; its state will always be > consistent within the session. if you need multiple copies/states, > then you use multiple sessions, or pick and choose who should be > refreshed. > > if you havent already, I totally overhauled the unit of work > documentation yesterady in response to the recent spate of confusion > over what an identity map and a unit of work is used for - http:// > www.sqlalchemy.org/docs/unitofwork.myt . It also details the refresh/ > expire/expunge methods as well as "per-object sessions" which may > also provide a way for you to get fresh copies (i.e. myobj = > mapper.using(Session()).get(1) will always be fresh...and unsaveable > unless you import it into another session since the original one > falls out of scope) > > also, I would recommend Fowler's "Patterns of Enterprise > Architecture" which is where I learned about all these patterns: > http://www.martinfowler.com/books.html#eaa . SQLAlchemy's ORM is a > python version of the "unit of work", "data mapper", and "identity > map" patterns described in this book. If those arent the patterns > you want to use, its going to be more of an uphill battle trying to > make SA be something its not....but even then, it is possible, youd > just have to write a layer on top of it to provide the patterns youre > looking for (or write an ORM on top of the SQL construction facilities). > > > On Mar 26, 2006, at 1:33 PM, Florian Boesch wrote: > > > Seemingly SA is fairly liberal with interpreting my wish to get > > stuff from the > > database. > > > > So what's the pattern to deal with "session" "caching"? > > > > I hear there's expunge etc. now, and expire, but that's all when I > > know what > > objects I want to have removed/expired/refreshed. Fact is, I don't, > > I wouldn't > > ask for an object from the database when I already had that very > > object... > > > > So is there a way to end a session by force? > > Can I disable all caching? > > How do I deal with that? > > > > > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a groundbreaking scripting > > language > > that extends applications into web and mobile media. Attend the > > live webcast > > and join the prime developer group breaking into this new coding > > territory! > > http://sel.as-us.falkag.net/sel? > > cmd=lnk&kid=110944&bid=241720&dat=121642 > > _______________________________________________ > > Sqlalchemy-users mailing list > > Sqlalchemy-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users > > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users