[Twisted-Python] Session trouble

Michal Pasternak michal at pasternak.w.lub.pl
Tue Dec 16 17:42:08 EST 2003


Hi,

On a page of the site I've got a form. The user enters values and submits
the form. Entered values are saved to session. If s/he gets back to the page
(=> encounters the same form), values are loaded from the session and the
form is filled with them. Everything worked okay, until I turned on caching.
Now, even if the test machine is on different subnet, the filled values are
presented to all connected users by default (eg. my friend, while testing
it, enters some data; I open a "clean" browser, without any cookies or such,
enter the page with the form - and I get the same data he entered!).

My question is simple: how do I get around this? Should I turn off the
caching (which speeds up page generation significantly, so I'd rather say
it's required)? Is it known issue? What am I doing wrong? Where should I RTFM?

I run the site server with twistd and RPY script.

This is my RPY script:

	cache()
	import myWeb
	resource = myWeb.RootPage()

This is how I save / load session values in myWeb:

     I have declared:
     
	class IPreferences(components.Interface):
    		pass
	class Preferences(components.Adapter):
    		__implements__ = IPreferences
	components.registerAdapter(Preferences, server.Session, IPreferences)

     Then, when I'm loading/saving values from/to session, I use:
     
        prefs = req.getSession(IPreferences)
	
-- 
Michal Pasternak :: http://pasternak.w.lub.pl :: http://winsrc.sf.net




More information about the Twisted-Python mailing list