Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #807 (closed enhancement: fixed)

Opened 13 years ago

Last modified 12 years ago

request: move some session configuration into tg

Reported by: jvanasco@… Owned by: anonymous
Priority: normal Milestone: 0.9a6
Component: TurboGears Version: 0.9a5
Severity: normal Keywords:
Cc:

Description

i'd really like it if sessions were wrapped into tg a bit

this is soley so that we can put in app.cfg:

tg_session.automatic_lock = True

which will call

cherrypy.session.acquire_lock()

at the beginning of each reqest

why would we want that?

a_ since TG has all the AJAX support, tg is prone to runing into session issues that caused cherrypy to add that feature in the first place. a transparent automagic lock should mitigate most problems before they even exist b_ it instantiates the session lock so sessions can be addressed in custom form validators , and elsewhere

I tried to figure out how to toss it into the code, but couldn't. If someone can point me to the right module, where an autolcok could be called ( it has to have access to the request ) i'll be happy to write it - can't be more than 3 lines in the cfg and 2 lines in the right class

the current way to implement sessions is a bit awkward too , i think wrapping more session info into tg would clarify it a bit ( right now (based on newsgroup postings) i have a session dsn in my app.cfg, and my controller sets the get_db() function on every request. thats really more of a hack than a methodology. i tried to do this functionality myself for 3 hours today, and couldn't wrap it into tg in a clean way (maybe thats why it doesn't exist?)

Attachments

tg_session-v1.diff Download (1.1 KB) - added by jvanasco@… 13 years ago.
tg session - version 1

Change History

comment:1 Changed 13 years ago by simon

  • Milestone set to 1.0

You could put it into controllers.expose(). This is where we initiate database transactions.

P.S. code in expose() is in a bit of a mess at the moment, try not to be put off by that! ;)

Changed 13 years ago by jvanasco@…

tg session - version 1

comment:2 Changed 13 years ago by jvanasco@…

ok. i made this patch that does the following:

  • calls an automatic lock on cherrypy.session if tg_session.automatic_lock is set ( i used the tg_session namespace as its tg specific and not a cherrypy setting , as the rest of the options are )
  • the file also now sets up a db connection for the session handling - but only if its postgres. i couldn't find any connect info for sessions in sqlite/mysql. i thought about putting it in model.py along with the rest of the 'db' code, but then i realized that sessions could be not db based ( like using a filstructure or memory ). something like this might be better off where the config is parsed, and chained to support post/mysql/files/and a user hook.

comment:3 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from 1.0 to 0.9a6

committed in [1461]. Note that I changed the config variable to tg.session.automatic_lock (replacing the initial _ with a .) which is more in line with the rest of our config variables.

Note: See TracTickets for help on using tickets.