diff options
| author | Paul Everitt <paul@agendaless.com> | 2013-09-24 06:43:47 -0400 |
|---|---|---|
| committer | Paul Everitt <paul@agendaless.com> | 2013-09-24 06:43:47 -0400 |
| commit | 4c08a4cf1d22050527f610f8a0287a8eead522d4 (patch) | |
| tree | 5c33516b2ec37628eb3cb11ee51485bbb8e347fc /docs/narr | |
| parent | 55867d510658e5454e6b73055b944694b69f5668 (diff) | |
| parent | fde65302aee7d6d3ee57af06082fb4ab34e2cda6 (diff) | |
| download | pyramid-4c08a4cf1d22050527f610f8a0287a8eead522d4.tar.gz pyramid-4c08a4cf1d22050527f610f8a0287a8eead522d4.tar.bz2 pyramid-4c08a4cf1d22050527f610f8a0287a8eead522d4.zip | |
Merge branch 'master' of https://github.com/Pylons/pyramid
Diffstat (limited to 'docs/narr')
| -rw-r--r-- | docs/narr/viewconfig.rst | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst index 76cf1daac..7c76116f7 100644 --- a/docs/narr/viewconfig.rst +++ b/docs/narr/viewconfig.rst @@ -822,7 +822,7 @@ of this: def delete(self): return Response('delete') - if __name__ == '__main__': + def main(global_config, **settings): config = Configurator() config.add_route('rest', '/rest') config.add_view( @@ -831,9 +831,10 @@ of this: RESTView, route_name='rest', attr='post', request_method='POST') config.add_view( RESTView, route_name='rest', attr='delete', request_method='DELETE') + return config.make_wsgi_app() To reduce the amount of repetition in the ``config.add_view`` statements, we -can move the ``route_name='rest'`` argument to a ``@view_default`` class +can move the ``route_name='rest'`` argument to a ``@view_defaults`` class decorator on the RESTView class: .. code-block:: python @@ -857,12 +858,13 @@ decorator on the RESTView class: def delete(self): return Response('delete') - if __name__ == '__main__': + def main(global_config, **settings): config = Configurator() config.add_route('rest', '/rest') config.add_view(RESTView, attr='get', request_method='GET') config.add_view(RESTView, attr='post', request_method='POST') config.add_view(RESTView, attr='delete', request_method='DELETE') + return config.make_wsgi_app() :class:`pyramid.view.view_defaults` accepts the same set of arguments that :class:`pyramid.view.view_config` does, and they have the same meaning. Each |
