|
List Info
Thread: Re: simplify session access
|
|
| Re: simplify session access |

|
2007-04-23 09:22:15 |
|
well, couldn';t you just use session = cherrypy.session at the beginning of your code? instead of creating a class that wrapps evertything of this module?
2007/4/23, AndCycle < andcycle andcycle.idv.tw">
andcycle andcycle.idv.tw>: On Apr 23, 4:07 am, fumanchu < fuman... amor.org">
fuman... amor.org> wrote: > On Apr 22, 9:28 am, AndCycle < andcy... andcycle.idv.tw">andcy... andcycle.idv.tw> wrote: > That's code, all right, but how does it simplify session access?
I have been stay on php for a while and moving to python, under cherrypy, session obj create when your page got request, at the import stage there is no such thing called session, so you can't using from cherrypy import * at the begining and using
session, instead you have to import cherrypy then called cherrypy.session in your page handler, personally I don't like to type all the cherrypy.session, this is really annoy when I do know where my variable placed,
that's the reason I made a lazy called obj to do this job.
-- " A melhor maneira para se destacar é mostrando o que você produziu, e não dizendo às pessoas o que você sabe, o que quer fazer ou quantas formações você tem."
John Carmack Diretor Técnico e Co-Fundador da ID Software
Ele nunca se formou...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To post to this group, send email to cherrypy-users googlegroups.com To unsubscribe from this group, send email to cherrypy-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: simplify session access |
  United States |
2007-04-23 11:36:24 |
AndCycle wrote:
> at the import stage there is no such thing called
session
and Rodrigo Renie Braga replied:
> well, couldn't you just use session = cherrypy.session
> at the beginning of your code? instead of creating a
class
> that wrapps evertything of this module?
No, because cherrypy.session doesn't exist until the first
request is
processed. This is so because the type of session storage is
determined
by a config entry, which isn't processed until request time.
Somebody
should change that so it (and a few other session config
entries) is
only specifiable in a global or app root (and then don't
pass it to
session.init), but until that day, you can do the
following:
cherrypy.session =
cherrypy._ThreadLocalProxy('session')
If you're using FileSession, you'll lose the "check for
stale lockfiles
at startup" step, but that's not critical.
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-2]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|