CherryPy and web.py

22 views
Skip to first unread message

xrfang

unread,
Oct 31, 2009, 4:28:55 AM10/31/09
to web.py
What is the relationship between web.py and CherryPy? What does
web.py offers more than a bare CherryPy (I heard that web.py is based
on CherryPy).

And, if I use web.py on Goole AppEngine do I still need CherryPy? i.e.
I have an impression that CherryPy is a web server while web.py is a
framework?? I might be very wrong because I just browsed CherryPy
tutorial...

Please clarify these, thanks a lot!

Anand Chitipothu

unread,
Oct 31, 2009, 4:33:03 AM10/31/09
to we...@googlegroups.com

web.py is not based on CherryPy. web.py uses WSGI server provided by
CherryPy as development web server and it not used when you are
running your app with apache, lighttpd or app engine.

Anand

xrfang

unread,
Oct 31, 2009, 10:21:41 AM10/31/09
to web.py
That clarified a LOT! :) I finished reading CherryPy tutorial and
does not like its url dispatching mechanism at all.

But one small issue on webpy side: while it is clear to use a GET and
a POST method, what if I would like to use one method to handle either
POST or GET?

Thanks,

Chris Brannon

unread,
Oct 31, 2009, 10:27:26 AM10/31/09
to we...@googlegroups.com
xrfang <xrf...@gmail.com> wrote:
> But one small issue on webpy side: while it is clear to use a GET and
> a POST method, what if I would like to use one method to handle either
> POST or GET?

class foo_handler:
def GET(self):
# do whatever

POST = GET

-- Chris

geekbuntu

unread,
Nov 7, 2009, 10:10:15 AM11/7/09
to web.py
so there is no spoon - i mean POST?
there is only GET(?)

Angelo Gladding

unread,
Nov 7, 2009, 2:06:57 PM11/7/09
to we...@googlegroups.com
If you want to use GET and POST for the same purpose set them equal to each other as Chris demonstrated. This is not ideal.

There is a spoon, ahem POST. There is also support for HEAD and DELETE afaik. Following is an example using memcache as a simple key/value store. The idea is to use GET to read the collection and POST to write to it.

paths = ('/', 'Foo')
app = web.application(paths, globals())

db = memcache.Client(['127.0.0.1:11212'])
db.set('foo', '0')

class Foo:
    def GET(self):
        return db.get('foo')
    def POST(self):
        db.incr('foo')  # increment foo
        raise web.seeother('/')

GET=0, GET=0, GET=0, POST~>GET=1, GET=1, POST~>GET=2

Let me know if that helps.
--
Angelo Gladding
ang...@gladding.name
http://angelo.gladding.name/
E69E 47E8 5C3A 96E5 C70F
D931 F35C ACBA 6F39 9611
Reply all
Reply to author
Forward
0 new messages