Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rickmak/pyramid_rest_route
https://github.com/rickmak/pyramid_rest_route
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rickmak/pyramid_rest_route
- Owner: rickmak
- License: mit
- Created: 2015-07-14T03:51:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-20T10:56:31.000Z (about 9 years ago)
- Last Synced: 2024-12-06T08:47:02.550Z (2 months ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Pyramid helper to create restful route.
Using URL Dispatch and class base view.
At pyramid booststrap
```
def main(global_config, **settings):
config = Configurator(settings=settings)
config.include("pyramid_resources")
```Registering route with `AppView`
```
config.add_rest_route('app', 'apps', AppView,
members={
'basic': 'edit',
'messaging': 'view',
'admin': 'edit',
},
collections={
'paid': 'admin',
},
factory=RootFactory)```
A simple `AppView` implementation
```
class AppView(RestView):renderers = {
'basic': '/app/basic.mako'
}def basic(self):
return {
'location': 'Render at basic.mako'
}@view_config(
route_name='paid_app',
renderer='json',
custom_predicates=(allowed_extension(*['.json']),)
permission='read')
def paid(self):
return {
"message": "using json renderer on json extension"
}```