Thread: [SQLObject] sqlobject with wsgi
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <jo...@ma...> - 2015-12-14 07:49:12
|
I seem to be having troubles getting sqlobject to play nicely with wsgi. In short, sqlobject seems to be returning the same data that was fetched before each time, until Apache is restarted. Example code: (much simplified) now = Table_Now.get(1) data["some_field"] = now.some_field //do something with data{} but even though the row being returned (I simplified it to the code above with a single row to try to pinpoint the problem) is actually being changed in the SQL db (mySQL) sqlobject always returns the same, old data... I did see mentioned somewhere about "sqlobject.wsgi_middleware," but I can't seem to figure out how that is supposed to be implemented, and unfortunatly, there doesn't seem to be any documentation covering that anywhere... Any help would be much appreciated! |
From: <jo...@ma...> - 2015-12-14 07:57:11
|
It appears that I am retarded. For some reason, the thought that a wsgi instance might not reload stuff never entered my head, because I thought "Oh, it's in a function even, there's no way those bits can be carrying over." But... of course the actual database bits have already been imported, and they don't get reloaded every time.... and wouldn't you know it, since stuff in the DB is being modified by something else OTHER THAN than the wsgi application, I need to use: now = Table_Now.get(1) now.sync() for my previous example. Hopefully this will help someone else making the same stupid mistakes as I did. --- Sent from my new email address: jo...@ma... On 2015-12-13 11:34 pm, jo...@ma... wrote: > I seem to be having troubles getting sqlobject to play nicely with > wsgi. > > In short, sqlobject seems to be returning the same data that was > fetched > before each time, until Apache is restarted. > > Example code: (much simplified) > > now = Table_Now.get(1) > data["some_field"] = now.some_field > //do something with data{} > > but even though the row being returned (I simplified it to the code > above with a single row to try to pinpoint the problem) is actually > being changed in the SQL db (mySQL) sqlobject always returns the same, > old data... > > I did see mentioned somewhere about "sqlobject.wsgi_middleware," but I > can't seem to figure out how that is supposed to be implemented, and > unfortunatly, there doesn't seem to be any documentation covering that > anywhere... > > Any help would be much appreciated! > > ------------------------------------------------------------------------------ > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss |
From: Oleg B. <ph...@ph...> - 2015-12-14 11:36:27
|
Hi! On Sun, Dec 13, 2015 at 11:57:05PM -0800, jo...@ma... wrote: > It appears that I am retarded. > > For some reason, the thought that a wsgi instance might not reload stuff > never entered my head, because I thought "Oh, it's in a function even, > there's no way those bits can be carrying over." But... of course the > actual database bits have already been imported, and they don't get > reloaded every time.... and wouldn't you know it, since stuff in the DB > is being modified by something else OTHER THAN than the wsgi > application, I need to use: > > now = Table_Now.get(1) > now.sync() The "problem" is that SQLObject caches fetched rows. The cache is in the DB connection object. You can clear the cache manually, or disable caching completely: when you create a DBConnection instance pass "cache=False" parameter to it. > for my previous example. > > Hopefully this will help someone else making the same stupid mistakes as > I did. > > --- > Sent from my new email address: jo...@ma... > > On 2015-12-13 11:34 pm, jo...@ma... wrote: > > I seem to be having troubles getting sqlobject to play nicely with > > wsgi. > > > > In short, sqlobject seems to be returning the same data that was > > fetched > > before each time, until Apache is restarted. > > > > Example code: (much simplified) > > > > now = Table_Now.get(1) > > data["some_field"] = now.some_field > > //do something with data{} > > > > but even though the row being returned (I simplified it to the code > > above with a single row to try to pinpoint the problem) is actually > > being changed in the SQL db (mySQL) sqlobject always returns the same, > > old data... > > > > I did see mentioned somewhere about "sqlobject.wsgi_middleware," but I > > can't seem to figure out how that is supposed to be implemented, and > > unfortunatly, there doesn't seem to be any documentation covering that > > anywhere... > > > > Any help would be much appreciated! Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |