summaryrefslogtreecommitdiff
path: root/docs/narr
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2013-09-22 14:29:38 -0500
committerMichael Merickel <michael@merickel.org>2013-09-22 14:29:38 -0500
commitfde65302aee7d6d3ee57af06082fb4ab34e2cda6 (patch)
tree71f96deccd5d1f47daf4ba2d8686d956ad92181d /docs/narr
parent5e8eadb86aeede3c7c27d77a1be4c4d23c951252 (diff)
downloadpyramid-fde65302aee7d6d3ee57af06082fb4ab34e2cda6.tar.gz
pyramid-fde65302aee7d6d3ee57af06082fb4ab34e2cda6.tar.bz2
pyramid-fde65302aee7d6d3ee57af06082fb4ab34e2cda6.zip
try to clarify the docs to avoid "if '__main__'" confusion
Diffstat (limited to 'docs/narr')
-rw-r--r--docs/narr/viewconfig.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst
index 182676b29..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,6 +831,7 @@ 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_defaults`` class
@@ -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