I may can help. I forked web.py a long time ago so my codebase isn't
exactly the same but I have a few tricks for making sessions work. It may
also be worth looking at: http://webpy.org/cookbook/session_with_reloader
as well.
When I make my main application I run the following:
if web.config.get('_session') is None:
store = web.session.DBStore(self.db, 'sessions')
store.cleanup(10.0)
session = web.session.Session(app, store, initializer=self.initializer)
web.config._session = session
else:
session = web.config._session
I have a config.py file that I import into my main application that has a
function called session
def session():
return web.config._session
I import config into my sub apps and config.session().value works fine in
my application code.
When I create my render object for an app or subapp I do the following:
render._add_global(config.session, 'context')
which makes my session data available in my templetor pages as well:
$def with (title=None, data=None)
$var title: $:title
<p>$:context().value</p>
If configured properly you will be able to access your session data across
all your sub apps and inside all of your templetor docs.
On Saturday, March 7, 2015 at 10:52:44 PM UTC-6, Suhas Patil wrote:
>
> I am testing my web.py application using automated tests and the
> application is running on Apache. The automated tests always fail when the
> Apache is restarted but succeed when the tests are rerun even though
> nothing has changed in the code or the system. The tests assume no previous
> state of the system meaning they are designed to be run on a freshly
> installed software.
>
> When I investigated, I noticed that the session value in the database is
> overwritten by subsequent calls to the server. In other words, if I run
> following command in sequence then the first five or six times I only find
> one value stored in the database. Only subsequent calls to curl then start
> creating a new session entry in the table.
> $ curl -v http://www.example.com/foo
>
> As a result if my tests because I want to use webpy_session_id for taking
> the application through different code paths.
>
> $ curl -v --cookie
> 'webpy_session_id=49e10d40f342ee92c30eea76e0804af28718a63f;'
> http://www.example.com/foo
>
> I tried going through session.py module but I could not debug it on the
> server and didn't want to spend too much time on it. Does anybody have a
> solution for this?
>
> Thanks
>
> Suhas.
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.