After a whole day of struggling I came to the conclusion that this is more of a design flaw than a bug :
Appadmin is designed to check credentials with another application (admin). The default behaviour of the credential checking system does not allow any modification and has to be done with gluon/fileutils.py (i.e. a file-based session management of the 'admin' application). The only exception is Google App Engine (it is written in the code with a big 'if' statement) which uses Google's SDK. I think it is a shame that the implementation of GAE in web2py is so restrictive : it would be so much better if the code was written to be more open to other cloud services. Many services are emerging these days (e.g. : http://www.paasify.it/vendors) and Google is not necessarily the best answer for everyone. At least it is not the only answer that's for sure. On the whole "session management" subject : I think it is an interesting idea to be able to check for credentials through applications but as we allow sessions to be stored in a database for any application, 'admin' should also be able to manage sessions in a database... with all corresponding functions that are currently file-based (e.g. appadmin.py). [tl;dr] So far the only solution to my issue was to : 1. Remove appadmin.py from my app 2. Disable 'admin' application 3. Rewrite gluon/contrib/heroku.py (I put my current file attached to this reply) Now basically if you use the "detect_heroku" function then you can apply "session.connect(...)" in your model with no risk of sessions being lost no matter how many dynos you deploy on heroku. That's the best solution I found so far, although far from perfect. On Wednesday, November 26, 2014 4:15:50 PM UTC+1, Anthony wrote: > > On Wednesday, November 26, 2014 8:34:58 AM UTC-5, Louis Amon wrote: >> >> I can’t find any documentation about settings.cfg. >> >> How does it work ? Where is it loaded ? Is it application-specific ? >> > > settings.cfg is in /web2py/applications/admin/ and is specific to the > admin app. Currently it only holds editor settings and is only read in when > editing. I suppose we could add a setting to specify where to store > sessions. > > Anthony > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
""" Usage: in web2py models/db.py from gluon.contrib.heroku import get_db db = get_db() """ import os from gluon import * from gluon.dal import ADAPTERS, UseDatabaseStoredFile,PostgreSQLAdapter detect_heroku = lambda: bool([n for n in os.environ.keys() if n[:18]+n[-4:]=='HEROKU_POSTGRESQL__URL']) class HerokuPostgresAdapter(UseDatabaseStoredFile,PostgreSQLAdapter): drivers = ('psycopg2',) #uploads_in_blob = True #ADAPTERS['postgres'] = HerokuPostgresAdapter def get_db(name = None, pool_size=10): if not name: names = [n for n in os.environ.keys() if n[:18]+n[-4:]=='HEROKU_POSTGRESQL__URL'] if names: name = names[0] if name: db = DAL(os.environ[name], pool_size=pool_size) current.session.connect(current.request, current.response, db=db) else: db = DAL('sqlite://heroku.test.sqlite') return db def get_db_uri(name = None): names = [n for n in os.environ.keys() if n[:18]+n[-4:]=='HEROKU_POSTGRESQL__URL'] if len(names) == 0: raise RuntimeError('No database available') if name is None: name = names[0] if not name in names: raise RuntimeError(name + ' is not available') uri = os.environ[name] return uri