Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Libraries

    PathTo 0.3.0

    Download button

    No screenshots available
    Downloads: 178  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Michael Burrows | More programs
    BSD License / FREE
    February 28th, 2010, 12:26 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    PathTo description

    Resource-oriented client APIs generated dynamically from auto-discovered, or locally-configured metadata

    The PathTo package contains resource-oriented client APIs generated dynamically from auto-discovered or locally-configured metadata.

    Support for the core metadata is provided in Python in DescribedRoutes.

    EXAMPLES

    Initialization

    Initialise from a server that supports auto-discovery via link headers:

    >>> from path_to import open_app
    >>> app = open_app('http://example.com/users/')


    Initialise with the metadata shown in the appendix at the end of this file. Typically provided by the server in JSON or YAML.
     
    >>> from path_to import Application
    >>> app = Application(...)
    >>> print app.resource_templates
    users users GET, POST http://example.com/users{.format}
     new new_user GET http://example.com/users/new{.format}
     {user_id} user GET, PUT, DELETE http://example.com/users/{user_id}{.format}
     edit edit_user GET http://example.com/users/{user_id}/edit{.format}
     articles user_articles GET, POST http://example.com/users/{user_id}/articles{.format}
     {article_id} user_article GET, PUT, DELETE http://example.com/users/{user_id}/articles/{article_id}{.format}


    Navigation

    Chaining, indexing, following relationships:

    >>> print app.users['dojo'].edit
    http://example.com/users/dojo/edit


    Positional and named parameters:

    >>> print app.user_article('dojo', 'foo', format='json')
    http://example.com/users/dojo/articles/foo.json


    Parameter dictionaries:

    >>> print app.user_article({'user_id': 'dojo', 'article_id': 'foo', format: 'json'})
    http://example.com/users/dojo/articles/foo.json


    Parameter inheritance:

    >>> app = open_app('http://example.com/users/', format='json')
    >>> print app.users['dojo'].articles['foo']
    http://example.com/users/dojo/articles/foo.json


    HTTP and JSON interfaces

    HTTP interface::

    >>> response = app.users['dojo'].articles['foo'].get(expected_status=200)
    >>> response = app.users['dojo'].articles['foo'].put(body, expected_status=302)


    Converting JSON content::

    >>> app = open_app('http://example.com/users/', format='json')
    >>> article = app.users['dojo'].articles['foo'].get(expected_status=200).parsed
    >>> article['title'] = 'Updated!'
    >>> response = app.users['dojo'].articles['foo'].put(article, expected_status=302)


    APPENDIX - SAMPLE METADATA

    templates = [
     {
     'name': 'users',
     'uri_template': 'http://example.com/users{.format}',
     'optional_params': ['format'],
     'options': ['GET', 'POST'],
     'resource_templates': [
     {
     'name': 'new_user',
     'rel': 'new',
     'uri_template': 'http://example.com/users/new{.format}',
     'optional_params': ['format'],
     'options': ['GET'],
     },
     {
     'name': 'user',
     'uri_template': 'http://example.com/users/{user_id}{.format}',
     'params': ['user_id'],
     'optional_params': ['format'],
     'options': ['GET', 'PUT', 'DELETE'],
     'resource_templates': [
     {
     'name': 'edit_user',
     'rel': 'edit',
     'uri_template': 'http://example.com/users/{user_id}/edit{.format}',
     'params': ['user_id'],
     'optional_params': ['format'],
     'options': ['GET']
     },
     {
     'name': 'user_articles',
     'rel': 'articles',
     'uri_template': 'http://example.com/users/{user_id}/articles{.format}',
     'params': ['user_id'],
     'optional_params': ['format'],
     'options': ['GET', 'POST'],
     'resource_templates': [
     {
     'name': 'user_article',
     'uri_template': 'http://example.com/users/{user_id}/articles/{article_id}{.format}',
     'params': ['user_id', 'article_id'],
     'optional_params': ['format'],
     'options': ['GET', 'PUT', 'DELETE']
     }
     ]
     }
     ]
     }
     ]
     }
     ]



    Product's homepage

    Requirements:

    · Python
    · DescribedRoutes
    · LinkHeader

      


    TAGS:

    resource-oriented API | Python library | locally-configured metadata | resource-oriented | API | metadata



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM