Discussion:
[bottlepy] Docker, Bottle, Beaker and strange behavior
Brian Brown
2015-05-05 22:39:52 UTC
Permalink
Hello,

I have a simple bottle app that uses beaker for session management. The app
being served by bottle is an SPA using polymer.

When I run the server in my local virtualenv, the sessions work as
expected. Other folks have run the app locally with the same results on Mac
and Linux. When I run the app in a Docker container every request generates
a new session.

I'm baffled as to any reason why this could happen. I've run a lot of
python apps in docker and haven't seen anything like this.

I'm using beaker 1.7.0, bottle 0.12.8, python 3.4.3, and the following is
the extract of how I'm setting up my app with bottle/beaker:
import bottle
from bottle import hook, request
from beaker.middleware import SessionMiddleware
import sys, os

session_opts = {
'session.type': 'memory',
'session.cookie_expires': 300,
'session.data_dir': './data',
'session.auto': True
}

@hook('before_request')
def setup_request():
request.session = request.environ['beaker.session']

@bottle.route('/<filepath:path>')
def server_static(filepath):
# Capture our query string parameters if they exist, put them into the
session
bug_id = bottle.request.query.bug_id;
update_type = bottle.request.query.utype;
print("QUERY?", bug_id, update_type, request.session)
if bug_id:
request.session['bug_id'] = bug_id

if update_type:
request.session['update_type'] = update_type
return bottle.static_file(filepath, root='public')


app = SessionMiddleware(bottle.app(), session_opts)
bottle.run(app=app, host='0.0.0.0', port=8080, debug=True, reloader=True)

When hitting the page with the query string parameters in the url, the
values are properly set on the session, but that session is never returned
again. only new sessions.

Again, this works fine outside of my docker container....

- Brian
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian Brown
2015-05-06 04:43:58 UTC
Permalink
An update - I just installed the app on an Ubuntu 15.04 system, no docker,
and it is doing the same thing - a new session for every request from the
same 'session'
Post by Brian Brown
Hello,
I have a simple bottle app that uses beaker for session management. The
app being served by bottle is an SPA using polymer.
When I run the server in my local virtualenv, the sessions work as
expected. Other folks have run the app locally with the same results on Mac
and Linux. When I run the app in a Docker container every request generates
a new session.
I'm baffled as to any reason why this could happen. I've run a lot of
python apps in docker and haven't seen anything like this.
I'm using beaker 1.7.0, bottle 0.12.8, python 3.4.3, and the following is
import bottle
from bottle import hook, request
from beaker.middleware import SessionMiddleware
import sys, os
session_opts = {
'session.type': 'memory',
'session.cookie_expires': 300,
'session.data_dir': './data',
'session.auto': True
}
@hook('before_request')
request.session = request.environ['beaker.session']
@bottle.route('/<filepath:path>')
# Capture our query string parameters if they exist, put them into the
session
bug_id = bottle.request.query.bug_id;
update_type = bottle.request.query.utype;
print("QUERY?", bug_id, update_type, request.session)
request.session['bug_id'] = bug_id
request.session['update_type'] = update_type
return bottle.static_file(filepath, root='public')
app = SessionMiddleware(bottle.app(), session_opts)
bottle.run(app=app, host='0.0.0.0', port=8080, debug=True, reloader=True)
When hitting the page with the query string parameters in the url, the
values are properly set on the session, but that session is never returned
again. only new sessions.
Again, this works fine outside of my docker container....
- Brian
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...