On 23-10-2007, Ian Bicking wrote:
> I redid the front page to make it more brief: 
> http://pythonpaste.org/webob/

Fine.  

I had to use it to understand what is the benefit of webob, the examples 
was not very clear in the first read.

The yaro's page was more clear to me for example.

>
> I stopped with the example, because I couldn't think of a good example. 
>   Maybe a different evening.  Suggestions of course welcome.

The problem will be to be practical but don't look like 'yet another 
framework' !

I liked your do-it-yourself-framework. Maybe a webob-only version ?

Each example should run alone with copy-paste and wsgiref as server.

Without webob:
--------------

import wsgiref.simple_server

def app(environ, start_response):
    start_response('200 OK', [('content-type', 'text/html')])
    return ['Hello world!']

wsgiref.simple_server.make_server('', 8080, app).serve_forever()


With webob:
-----------

import wsgiref.simple_server
from webob import Response, Request

def app(environ, start_response):
    req = Request(environ)
    res = Response(content_type='text/html')
    res.body = 'Hello world!'
    return res(environ, start_response)

wsgiref.simple_server.make_server('', 8080, app).serve_forever()

With form :
-----------

import wsgiref.simple_server
from webob import Response, Request

def app(environ, start_response):
    req = Request(environ)
    res = Response(content_type='text/html')
    you = req.params.get('you')
    if you:
        res.body_file.write('Hello %s' % you)
    res.body_file.write('''<form>
    Who are you ? <input name='you'>
    <input type='submit'>
    </form>''')

    return res(environ, start_response)

wsgiref.simple_server.make_server('', 8080, app).serve_forever()


with form and cookies :
-----------------------

import wsgiref.simple_server
from webob import Response, Request

def app(environ, start_response):
    req = Request(environ)
    res = Response(content_type='text/html')
    you_cookie = req.cookies.get('you')
    if you_cookie:
        res.body_file.write('I recognize you %s<br>' % you_cookie)
    you = req.params.get('you', you_cookie)
    if you:
        res.body_file.write('Hello %s' % you)
        res.set_cookie('you', you)
    res.body_file.write('''<form>
    Who are you ? <input name='you'>
    <input type='submit'>
    </form>''')

    return res(environ, start_response)

wsgiref.simple_server.make_server('', 8080, app).serve_forever()

-- 
William Dodé  -  http://flibuste.net
Informaticien indépendant

_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com

Reply via email to