lazr.restful¶
lazr.restful is a library for publishing Python objects through a RESTful web service. To tell lazr.restful which objects you want exposed and how, you annotate your existing Zope interfaces.
The WSGI example web service¶
The example web service in src/lazr/restful/example/wsgi/ is the best place to start understanding lazr.restful. It’s a very simple web service that uses a subset of lazr.restful’s features and can be run as a standalone WSGI application. An explanation of the code can be found in src/lazr/restful/example/wsgi/README.txt
The full example web service¶
To understand all of lazr.restful, you should look at the web service defined in src/lazr/restful/example/base/. It defines a simple application serving information about cookbooks and recipes. The interfaces (interfaces.py) are annotated with lazr.restful decorators that say which fields and methods to publish from IRecipe, ICookbook, and so on. The implementations of those interfaces are in root.py.
The machinery of lazr.restful takes the decorators in interfaces.py, and generates an interface that maps incoming HTTP requests to operations on the actual objects defined in root.py. You don’t have to do any HTTP server programming to get it to work (though at the moment you do have to know a fair amount about Zope).
You can test the example web service by running bin/test. The doctests in src/lazr/restful/example/base/tests use a fake httplib2 connection to simulate HTTP requests to the web service. You can watch the tests make GET, PUT, POST, PATCH, and DELETE requests to the web service. Start with root.txt.
Other code¶
Two other pieces of code might be of interest when you’re starting out.
declarations.py contains all the Python decorators. docs/webservice-declarations.txt shows how to use them.
docs/webservice.txt shows an example of a webservice that creates Entry and Collection classes directly rather than generating them with the declarations. If you want to use lazr.restful without using zope.schema, this is the test to look at.
Other Documents¶
- RESTful Web Services
- Example model objects
- Security
- Web Service Infrastructure Initialization
- Defining the resources
- Implementing the resources
- Custom operations
- Resource objects
- The Service Root Resource
- WADL documents
- Collection resources
- Pagination
- Custom operations
- Entry resources
- Named operation return values
- ETags
- Resource Visibility
- Stored file resources
- Field resources
- Requesting non available resources
- Manipulating entries
- Within a template
- Web Service API Declarations
- Exporting the data model
- Exporting entries
- Exporting a collection
- Exporting methods
- Exporting exceptions
- Export and inheritance
- Contributing interfaces
- Generating the webservice
- Versioned services
- Why the list of version strings?
- Error handling
- @operation_removed_in_version
- Mutators
- Destructor operations
- Security
- ZCML Registration
- Edge cases
- Exceptions on the web service
- LAZR’s field marshallers
- Adapting a browser request into a web service request
- LAZR Fields
- LAZR Interface Helpers
- URL generation
- Various utility functions
- Utilities to define security checkers
- Publishing multiple versions of a web service
- LAZR Debugging Helpers
- Django integration
- Contributing
- NEWS for lazr.restful
- 1.2.0
- 1.1.0 (2021-10-07)
- 1.0.4 (2021-09-13)
- 1.0.3 (2021-05-20)
- 1.0.2 (2021-05-14)
- 1.0.1 (2021-02-18)
- 1.0.0 (2021-01-21)
- 0.23.0 (2020-09-28)
- 0.22.2 (2020-09-02)
- 0.22.1 (2020-07-08)
- 0.22.0 (2020-06-12)
- 0.21.1 (2020-02-19)
- 0.21.0 (2019-12-17)
- 0.20.1 (2018-02-21)
- 0.20.0 (2017-06-29)
- 0.19.10 (2012-12-06)
- 0.19.9 (2012-10-23)
- 0.19.8 (2012-10-02)
- 0.19.7 (2012-09-26)
- 0.19.6 (2012-03-15)
- 0.19.5 (2012-03-13)
- 0.19.4 (2011-10-11)
- 0.19.3 (2011-09-20)
- 0.19.2 (2011-09-08)
- 0.19.1 (2011-09-08)
- 0.19.0 (2011-07-27)
- 0.18.1 (2011-04-01)
- 0.18.0 (2011-03-23)
- 0.17.5 (2011-03-15)
- 0.17.4 (2011-03-08)
- 0.17.3 (2011-03-08)
- 0.17.2 (2011-03-03)
- 0.17.1 (2011-02-23)
- 0.17.0 (2011-02-17)
- 0.16.1 (2011-02-16)
- 0.16.0 (No official release)
- 0.15.4 (2011-01-26)
- 0.15.3 (2011-01-21)
- 0.15.2 (2011-01-20)
- 0.15.1 (2011-01-19)
- 0.15.0 (2010-11-30)
- 0.14.1 (2010-10-24)
- 0.14.0 (2010-10-05)
- 0.13.3 (2010-09-29)
- 0.13.2 (2010-09-27)
- 0.13.1 (2010-09-23)
- 0.13.0 (2010-09-06)
- 0.12.1 (2010-09-02)
- 0.12.0 (2010-08-26)
- 0.11.2 (2010-08-23)
- 0.11.1 (2010-08-13)
- 0.11.0 (2010-08-10)
- 0.10.0 (2010-08-05)
- 0.9.29 (2010-06-14)
- 0.9.28 (2010-06-03)
- 0.9.27 (2010-06-01)
- 0.9.26 (2010-05-18)
- 0.9.25 (2010-04-14)
- 0.9.24 (2010-03-17)
- 0.9.23 (2010-03-11)
- 0.9.22 (2010-03-05)
- 0.9.21 (2010-02-23)
- 0.9.20 (2010-02-16)
- 0.9.19 (2010-02-15)
- 0.9.18 (2010-02-11)
- 0.9.17 (2009-11-10)
- 0.9.16 (2009-10-28)
- 0.9.15 (2009-10-21)
- 0.9.14 (2009-10-20)
- 0.9.13 (2009-10-19)
- 0.9.12 (2009-10-14)
- 0.9.11 (2009-10-12)
- 0.9.10 (2009-10-07)
- 0.9.9 (2009-10-07)
- 0.9.8 (2009-10-06)
- 0.9.7 (2009-09-24)
- 0.9.6 (2009-09-16)
- 0.9.5 (2009-08-26)
- 0.9.4 (2009-08-17)
- 0.9.3 (2009-08-17)
- 0.9.2 (2009-08-05)
- 0.9.1 (2009-07-13)
- 0.9 (2009-04-29)