From mjb at asplake.co.uk Fri Feb 26 13:18:04 2010 From: mjb at asplake.co.uk (Mike Burrows (@asplake)) Date: Fri, 26 Feb 2010 04:18:04 -0800 (PST) Subject: [Web-SIG] Announcing PathTo and DescribedRoutes for Python Message-ID: <27717520.post@talk.nabble.com> PathTo is a metadata-driven HTTP client that makes scripted server interaction easy: >>> import path_to >>> app = path_to.open_app('http://example.com/', format='json') >>> app.login.post(credentials, expected_status=302) >>> product = app.products['Foo'].get(expected_status=200).parsed >>> product['description'] = 'Updated!' >>> app.products['Foo'].put(product, expected_status=302) >>> app.products['Foo'].get(expected_status=200).parsed['description'] u'Updated!' The HTTP part comes by default from httplib2. DescribedRoutes defines the underlying metadata ("ResourceTemplates"). It is framework-independent (see note 1), but for Pylons there is provided a WSGI middleware component that generates the metadata in JSON and friendly text formats on demand from the routing specification (see note 2) and supports discovery via link headers. Links: 1. PathTo repo: http://bitbucket.org/asplake/path_to 2. PathTo on PyPi: http://pypi.python.org/pypi/PathTo/ 3. DescribedRoutes repo: http://bitbucket.org/asplake/described_routes 4. DescribedRoutes on PyPi: http://pypi.python.org/pypi/DescribedRoutes/ 5. An explanation of the above example (blogged) - http://positiveincline.com/?p=629 Notes: 1. Framework-independent and language-independent - the system was originally developed for Rails, and clients exist in Ruby and Javascript. It has been a while since interop has been tested in anger though. In the absence of server support, the PathTo client can be configured locally. 2. It assumes that routes are specified URI Template-style, e.g. "/products/{product_id}" (this is unlikely to change) and it needs variables to be named consistently in order to do a good job of inferring the resource hierarchy (but the algorithm should improve over time). Enjoy, Mike mjb at asplake.co.uk http://positiveincline.com http://twitter.com/asplake -- View this message in context: http://old.nabble.com/Announcing-PathTo-and-DescribedRoutes-for-Python-tp27717520p27717520.html Sent from the Python - web-sig mailing list archive at Nabble.com.