开发者

How can I make WSGI(Python) stateful?

开发者 https://www.devze.com 2022-12-11 03:23 出处:网络
I\'m quite new in Python world. I come from java and ABAP world, where their application server are able to handle stateful request.

I'm quite new in Python world. I come from java and ABAP world, where their application server are able to handle stateful request.

Is it also possible in python using WSGI?

Or stateful and stateless are handled in other lay开发者_Go百科er?


Usually, you don't work with "bare" WSGI. You work with web-frameworks, such as Pylons or TurboGears2.

And these contain a session-middleware, based on WSGI - called "Beaker". But if you work with the framework, you don't have to worry about that - you just use it.

But if you insist, you can of course use Beaker standalone.


I prefer working directly on wsgi, along with mako and psycopg.
It's good to know about Beaker, though I usually don't hold state in the server because I believe it reduces scalability. I either put it in the user's cookie, in the database tied to a token in the user's cookie, or in a redirect url.


Your question is a little vague and open-ended. First of all, WSGI itself isn't a framework, it's just the glue to connect a framework to the web server. Secondly, I'm not clear on what you mean when you say "state" -- do you mean storing information about a client on the server? If so, web frameworks (Pylons, Django, etc) allow you to store that kind of information in web session variables.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号