Lukas Almad Linhart
xlinl01 at vse.cz
Sun Oct 3 12:24:28 EDT 2004
Zdravim, s mod_pythonem pomerne silne zacinam a je to prechod z klasickeho pythonu a pomerne dlouhe dobe skriptovani v php, takze docela zmena. Kazdopadne se nebranim pouziti jinych handleru, ale psp ani spyce (byt se mi spyce libi) nechci pouzivat, zvlast proto, ze ani moc netouzim po vkladani python kodu primo do zdrojaku. Je nejaky problem s volanim session.save (pomalost etc.)? Vzhledem k tomu, ze si budu psat stejne vlastni template system, tak mi to nijak extra nevadi, asi min, nez pouzit nejakou implementaci, ktera bude nejak horsi (implementuje zbytecne kraviny, ne tak stabilni apod.). > Also, session id is stored as a cookie (pysid) on client side, so maybe no > need to print it each time into each link element. A co lide co maji vyple cookies? ;) > But there is something else id like to know -- is there a way how can i > rename the default name ('pysid') of a session -- ie. if im using 2 sites > on my server which both use session, there will be a problem. Koukal jsem do zdrojaku mod_pythonu a tam je prefix nastavitelny v Session.py, takze by to asi slo hacknout a predelat tak, aby to jelo generovalo nejaky prefix nebo tak neco. A nebo, pouzit DbmSession, na coz se asi stejne chystam :-] Kazdopadne dik za rady (spoluzaku ;)), -- Lukas "Almad" Linhart [:: http://www.Include.cz/ ::] [:: Including Your wishes ::] [:: Almad at Include.cz ::] E-mail Martin Slouf ze dne Sun 3. of October 2004 08:55: > Hi, > > look at the code listening bellow, you have to call session.save() (handler > request) manually at end of each request. maybe using another handler > (mod_python.servlet -- http://home.comcast.net/~d.popowich/mpservlets/) is > more convenient. > > Also, session id is stored as a cookie (pysid) on client side, so maybe no > need to print it each time into each link element. > > But there is something else id like to know -- is there a way how can i > rename the default name ('pysid') of a session -- ie. if im using 2 sites > on my server which both use session, there will be a problem. > > reagrds, martin. > > (možná můžu i česky? :) > > - - - - > > #! /usr/bin/env python > # -*- ISO-8859-2 -*- > > # Time-stamp: < session_test.py (15:20 25.9.2004) > > > from mod_python import apache > from mod_python import Session > > def index(req): > s = Session.Session(req, timeout = 1) > if (s.is_new()): > s["count"] = 0 > s["tmp"] = "message" > s["list"] = ["1", "b", "2", "d"] > s["square"] = Square(5) > s["count"] += 1 > req.write(s.id() + "\n") > req.write(str(s) + "\n") > req.write(str(s["square"].a) + "\n") > s.save() > > def invalidate(req): > s = Session.Session(req) > s.invalidate() > req.write("invalidate") > > class Square: > def __init__(self, a = 0): > self.a = 0 > def __str__(self): > return "Square: a = %d" % (self.a,) > def __repr__(self): > return str(self) > > - - - - > > # .htacces > > AddHandler mod_python .py > PythonHandler mod_python.publisher > PythonDebug On > PythonAutoReload On -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 190 bytes Desc: not available Url : http://modpython.org/pipermail/mod_python/attachments/20041003/b30b35bd/attachment.bin
|