GithubHelp home page GithubHelp logo

pombredanne / path-to-py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asplake/path-to-py

1.0 0.0 0.0 67 KB

Python port of path-to - resource-oriented client APIs generated dynamically from server-provided or locally-configured metadata.

Home Page: http://positiveincline.com/?tag=path-to

License: Other

path-to-py's Introduction

path-to-py

DESCRIPTION

Python port of path-to - resource-oriented client APIs generated dynamically from server-provided or locally-configured metadata.

Support for the core metadata is provided in Python in described_routes-py.

For further information see roadmap for the original Ruby-based described_routes and path-to at positiveincline.com/?p=213.

CONTENTS

  • EXAMPLES

  • AUTHOR AND CONTACT INFORMATION

  • APPENDIX - SAMPLE JSON

EXAMPLES

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(...)

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 = app.with_params(format='json')   # or app = app(format='json')
>>> print app.users['dojo'].articles['foo']
http://example.com/users/dojo/articles/foo.json

Future versions will add HTTP client methods (get, put, post, etc). In the meantime, str(path) or path.uri will yield a URI string that can be passed to an existing HTTP client library.

REQUIREMENTS

AUTHOR AND CONTACT INFORMATION

Mike Burrows (asplake), email [email protected], website positiveincline.com (see articles tagged path-to)

APPENDIX - SAMPLE METADATA

<br/>

[
    {
        'name':               'users',
        'uri_template':       'http://example.com/users{-prefix|.|format}',
        'optional_params':    ['format'],
        'options':            ['GET', 'POST'],
        'resource_templates': [
            {
                'name':               'new_user',
                'rel':                'new',
                'uri_template':       'http://example.com/users/new{-prefix|.|format}',
                'optional_params':    ['format'],
                'options':            ['GET'],
            },
            {
                'name':               'user',
                'uri_template':       'http://example.com/users/{user_id}{-prefix|.|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{-prefix|.|format}',
                        'params':          ['user_id'],
                        'optional_params': ['format'],
                        'options':         ['GET']
                    },
                    {
                        'name':            'user_articles',
                        'rel':             'articles',
                        'uri_template':    'http://example.com/users/{user_id}/articles{-prefix|.|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}{-prefix|.|format}',
                                'params':             ['user_id', 'article_id'],
                                'optional_params':    ['format'],
                                'options':            ['GET', 'PUT', 'DELETE']
                            }
                        ]
                    }
                ]
            }
        ]
    }
]

path-to-py's People

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.