471,349 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

How to do python and RESTful

Hi all,

I want to make a web service application in python and keywords are
RESTful, python and nice urls(urls mapped to python objects).

I don't want a big framework but a nice small one, that can just do
the things I want.

I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?

Can some one here point me some where I can read about python and
RESTful or have some experiences with other?

Any help is apricieted.

Regards Marc

Sep 5 '07 #1
6 2773
MarkyMarc wrote:
Hi all,

I want to make a web service application in python and keywords are
RESTful, python and nice urls(urls mapped to python objects).

I don't want a big framework but a nice small one, that can just do
the things I want.

I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?

Can some one here point me some where I can read about python and
RESTful or have some experiences with other?

Any help is apricieted.

Regards Marc
Here is a crude version, if you check out CherryPy there exists a
RESTful module for it floating around. Plus you will get the power or
CherryPy for your apps. I do not have the urls offhand but google should
yeild exactly what you need.

import BaseHTTPServer

class REST(BaseHTTPServer.BaseHTTPRequestHandler):

"""
You can implement and do_* method you want
"""

def do_GET(self):
self.wfile.write("get")

def do_POST(self):
self.wfile.write("post")

def do_PUT(self):
self.wfile.write("put")

def do_DELETE(self):
self.wfile.write("delete")

def main(server_class=BaseHTTPServer.HTTPServer, handler_class=REST):
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()

if __name__ == '__main__':
main()

Not fully tested but should get on your feet.

Hope this helps.

Adonis Vargas
Sep 6 '07 #2
MarkyMarc a écrit :
Hi all,

I want to make a web service application in python and keywords are
RESTful, python and nice urls(urls mapped to python objects).

I don't want a big framework but a nice small one, that can just do
the things I want.

I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?

Can some one here point me some where I can read about python and
RESTful or have some experiences with other?
You may want to have a look at Pylons (http://pylonshq.com).
Sep 6 '07 #3
On Sep 5, 9:54 pm, MarkyMarc <marcsgbrevko...@gmail.comwrote:
Hi all,

I want to make a web service application in python and keywords are
RESTful, python and nice urls(urls mapped to python objects).

I don't want a big framework but a nice small one, that can just do
the things I want.

I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?

Can some one here point me some where I can read about python and
RESTful or have some experiences with other?

Any help is apricieted.

Regards Marc
For the client part, there is an easy_installable library called
restclient (which
I tested very little but it seems to work). For the server part, I am
sure there are
many available, but is also easy to write your own. For instance,
using WSGI,
you can do something like:

def restful_wsgi_app(env, resp):
meth = env.get('REQUEST_METHOD')
if meth == 'GET':
...
elif meth == 'POST':
...
elif meth == 'PUT':
....
elif meth == 'DELETE':
...
else:
raise ValueError('Unknown HTTPMethod %r!!' % meth)
...

Michele Simionato

Sep 6 '07 #4
Michele Simionato <mi***************@gmail.comwrites:
On Sep 5, 9:54 pm, MarkyMarc <marcsgbrevko...@gmail.comwrote:
Hi all,

I want to make a web service application in python and keywords are
RESTful, python and nice urls(urls mapped to python objects).

I don't want a big framework but a nice small one, that can just do
the things I want.

I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?

Can some one here point me some where I can read about python and
RESTful or have some experiences with other?

Any help is apricieted.

Regards Marc

For the client part, there is an easy_installable library called
restclient (which
I tested very little but it seems to work). For the server part, I am
sure there are
many available,
Another good option is Twisted. The Twisted book from O'Reilly has
examples of using the twisted HTTP client as a REST client. I'm using
that fairly succesful.

S.
Sep 6 '07 #5
MarkyMarc wrote:
Hi all,

I want to make a web service application in python and keywords are
RESTful, python and nice urls(urls mapped to python objects).

I don't want a big framework but a nice small one, that can just do
the things I want.
Translation: I am only interested in a solution that has anticipated my
needs almost exactly. [?]
I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?
Would you care to explain why quixote needs to be "uptodate"? Surely it
either does what you want or it doesn't? If it dies, then it hardly
matters how "up to date" it is. Are you also concerned that some parts
of Python remains unchanged since before 1.5.2, now almost tne years old?
Can some one here point me some where I can read about python and
RESTful or have some experiences with other?

Any help is apricieted.
I hope you don't regard this as being unhelpful. I would encourage you
to focus on finding a system that meets your (functionality)
requirements. If you want "up to date" then C# is that way ---;-)

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Sep 6 '07 #6
[MarkyMarc]
>I have be looking at quixote, but is this uptodate? "plain"
mod_python, can this make url to http put,get,delete and post?
[Steve Holden]
Would you care to explain why quixote needs to be "uptodate"? Surely it
either does what you want or it doesn't? If it dies, then it hardly
matters how "up to date" it is. Are you also concerned that some parts
of Python remains unchanged since before 1.5.2, now almost tne years old?
FWIW, I have used Quixote on two (v. small-scale) production websites,
both started several years ago when there were fewer web toolkits in
the Python universe. Every so often I consider reworking one or other
of them into one of the newer (read: more recently noised about)
toolkits/frameworks. But they work fine as they are, so why bother?
As a matter of fact, one uses Quixote v1, the other uses v2 which
occasionally throws me when I'm doing some work on both at the same
time!

TJG
Sep 6 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Jeremy Jones | last post: by
1 post views Thread by SimonW | last post: by
2 posts views Thread by mazdotnet | last post: by
2 posts views Thread by Guilherme Polo | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.