andreas.ulbrich at gmx.net
Mon Sep 23 10:11:04 EDT 2002
> Please can anyone help me.
> My problem:
> I'm trying to program a web application with python. This tool has to
> provide diffrent languages. The user has to choose the language at the
> beginning. So i have to save the information which language the user
> chooses. I think this is a perfect example for using sessions.
> The only problem is I've got no idea how to realise this in python.
> Please help me as soon as you can because I have to solve this problem
> very quickly.
> hoping to hear from you soon
Whenever I need to write a web-application I do use jython and write
servlets. This combines the power of Servlet/JSP with the worlds best
a jython servlet would look like this:
from javax.servlet.http import HttpServlet
class MyServlet(HttpServlet) :
def doGet(self, request, response) :
session = request.getSession(1)
lang = session.getAttribute('language')
if not lang :
# initialise the session (i.e. choose language)
# produce output suitable to lang
if lang == 'DE' :
print >> res.writer, "Hallo Welt!"
print >> res.writer, "Hello World!"
There are other solutions. I believe that Zope offers session-management
More information about the Python-list