How to do python and RESTful

Discussion in 'Python' started by MarkyMarc, Sep 5, 2007.

  1. MarkyMarc

    MarkyMarc Guest

    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
    MarkyMarc, Sep 5, 2007
    #1
    1. Advertising

  2. 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
    Adonis Vargas, Sep 6, 2007
    #2
    1. Advertising

  3. 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).
    Bruno Desthuilliers, Sep 6, 2007
    #3
  4. On Sep 5, 9:54 pm, 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


    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
    Michele Simionato, Sep 6, 2007
    #4
  5. Michele Simionato <> writes:

    > On Sep 5, 9:54 pm, 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

    >
    > 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.
    Stefan Arentz, Sep 6, 2007
    #5
  6. MarkyMarc

    Steve Holden Guest

    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 -------------
    Steve Holden, Sep 6, 2007
    #6
  7. MarkyMarc

    Tim Golden Guest

    [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
    Tim Golden, Sep 6, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SimonW

    RESTful Python

    SimonW, Jan 30, 2004, in forum: Python
    Replies:
    2
    Views:
    989
    A.M. Kuchling
    Jan 31, 2004
  2. Julio F Schwarzbeck

    RESTful API for own python application

    Julio F Schwarzbeck, Feb 2, 2013, in forum: Python
    Replies:
    0
    Views:
    161
    Julio F Schwarzbeck
    Feb 2, 2013
  3. dieter
    Replies:
    0
    Views:
    142
    dieter
    Feb 3, 2013
  4. Eric Frederich
    Replies:
    0
    Views:
    162
    Eric Frederich
    Apr 25, 2013
  5. Chris “Kwpolska†Warrick

    Re: Python platform/framework for new RESTful web app

    Chris “Kwpolska†Warrick, Apr 27, 2013, in forum: Python
    Replies:
    0
    Views:
    134
    Chris “Kwpolska†Warrick
    Apr 27, 2013
Loading...

Share This Page