On Dec 13, 2010, at 3:38 AM, Alexander Zhabotinskiy wrote:
> I have wrote a big project on pylons. Unfortunately, I have not test
> it enough before deployment. Later I start getting an error.
> Address http://siteurl/c/2010_9999 should select client (by the card
> number 2010_9999) and write his data to session['SELECTED_CARD'], but
> sometimes user gets data from previous session instead of actual or
> even data from the session of another user. (Wrong rendered pages
> returns faster, like browser cache)
What version of Beaker? Are you using the latest?
> After a long search I am inclined to think that problem is in beaker
> session. Maybe it has something to do with the system time as errors
> appear about 11am.
> I'm storing sessions in the database. I have noticed that if I clean
> old sessions from DB at the end of the day, then the next day less
> mistakes happens.
I would hope not, there's been lots of large deployments using db sessions. Can
you share your session configuration (minus the secret key of course) info?
> Here is 2 controllers - account, customer and the routing rule.
>
> # routing.py
> map.connect('/c/{id}', controller='account', action='set_сustomer')
Switch to the following to avoid having to do the id is None check:
map.connect('/c/{id:\d|]w+}'.....)
> #account.py
> def set_сustomer(self, id=None):
> num = id.replace('_','/')
> # is customer in DB?
> try:
>
> Session.query(Customer.num).filter(Customer.num==num).one()
> except:
> h.flash.set_message(u'Try to import customer from
> old DB ' + num)
> redirect(url('/account/search'))
> else:
> session['SELECTED_CARD'] = num
> session.save()
> redirect(url('/customer')) # redirects after write
> session
I don't see any reason that'd cause a problem. What kind of setup do you have
in production? Are you using any caching proxies (squid, varnish, nginx/apache
in certain modes) that could be inadvertently caching pages for other sessions?
Cheers,
Ben
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.