Skip to main content

Simple helper for creating rest route and view

Project description

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"
}


```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyramid_rest_route-0.2.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file pyramid_rest_route-0.2.tar.gz.

File metadata

File hashes

Hashes for pyramid_rest_route-0.2.tar.gz
Algorithm Hash digest
SHA256 b912688578bfd23636e26463d23a03b36c13df4286c718e529a40d43024ba87e
MD5 44d36485366e262c04ebd2e13cac285b
BLAKE2b-256 b9f7d5def3b230446da6d5c97db8dc489232f567dc0a4dfcd8b0e4ade40b50ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page