Frederic Peters wrote: >Titus Brown wrote: > > > >>still thinking about sessions. Does anyone out there use the >>SessionManager.abort_changes & SessionManager.commit_changes >>functionality? If so, I'd be interested in hearing from you >>privately; I'm particularly interested in what backend storage >>systems you're using. >> >> > >Not privately, as requested later :) > >I probably should introduce myself since it is my first post. I have >been using Quixote for something like three weeks now and I am really >happy about the experience. > >Much like everybody I needed persistent sessions :) and subclassed >SessionsManager to get them. My scheme was only supposed temporary >and is somewhat hackish. I have a directory (whatever/sessions/) and >I use pickle to read/write session objets to that directory, one file >per session, the name being session_id. > >So I subclassed SessionsManager and added keys(), values(), items, >has_key(), __setitem__(), __getitem__(), __delitem__() to get proper >dictionary behaviour (as you wrote "this makes subclassing a bit >annoying") and commit_changes() which writes down the file on disk. > > Note how this is a perfect example of why we need persistent sessions in Quixote. There's a file session store that does exactly this; it's called DirMapping.py and was in a Quixote 1.x demo but was dropped for Quixote 2. I copied it into my application and have been using it happily, although I had to add file locking (fcntl) to prevent multiprocess servers from stomping on each other's files. This worked fine until it crashed and burned on a Mac server this week. Either Unix file locking doesn't work on the Mac or it's not compiled into the version of Python that's shipped. So I may just use dictionary sessions instead, with the caveat that the app must not run on multiprocess servers (e.g., fcgi). (I'm using SCGI with max_children=1, although I assume that makes it de facto synchronous; i.e., one request at a time.) If you (Frederic) want the code I can send it. But I do plan to try Titus's code soon.