summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-12-16 04:54:09 -0500
committerChris McDonough <chrism@plope.com>2011-12-16 04:54:09 -0500
commit10f1b5c35072c5499f3504dc261fb3c67a90c70d (patch)
tree65d844890e4333109b92cfeb91c11d639ae43f07 /docs
parent9003a8bba654f98933b98dacac67760cff73e1c5 (diff)
downloadpyramid-10f1b5c35072c5499f3504dc261fb3c67a90c70d.tar.gz
pyramid-10f1b5c35072c5499f3504dc261fb3c67a90c70d.tar.bz2
pyramid-10f1b5c35072c5499f3504dc261fb3c67a90c70d.zip
stamp out paste.httpserver usage
Diffstat (limited to 'docs')
-rw-r--r--docs/designdefense.rst12
-rw-r--r--docs/narr/advconfig.rst20
-rw-r--r--docs/narr/configuration.rst11
-rw-r--r--docs/narr/firstapp.rst24
-rw-r--r--docs/narr/hooks.rst5
5 files changed, 41 insertions, 31 deletions
diff --git a/docs/designdefense.rst b/docs/designdefense.rst
index 80675ce83..59b0e5a2d 100644
--- a/docs/designdefense.rst
+++ b/docs/designdefense.rst
@@ -1628,8 +1628,8 @@ comments take into account what we've discussed in the
.. code-block:: python
:linenos:
- from pyramid.response import Response # explicit response objects, no TL
- from paste.httpserver import serve # explicitly WSGI
+ from pyramid.response import Response # explicit response, no TL
+ from wsgiref.simple_server import make_server # explicitly WSGI
def hello_world(request): # accepts a request; no request thread local reqd
# explicit response object means no response threadlocal
@@ -1640,7 +1640,8 @@ comments take into account what we've discussed in the
config = Configurator() # no global application object.
config.add_view(hello_world) # explicit non-decorator registration
app = config.make_wsgi_app() # explicitly WSGI
- serve(app, host='0.0.0.0') # explicitly WSGI
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever() # explicitly WSGI
Pyramid Doesn't Offer Pluggable Apps
------------------------------------
@@ -1736,7 +1737,7 @@ If you can understand this hello world program, you can use Pyramid:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
@@ -1747,7 +1748,8 @@ If you can understand this hello world program, you can use Pyramid:
config = Configurator()
config.add_view(hello_world)
app = config.make_wsgi_app()
- serve(app)
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
Pyramid has ~ 650 pages of documentation (printed), covering topics from the
very basic to the most advanced. *Nothing* is left undocumented, quite
diff --git a/docs/narr/advconfig.rst b/docs/narr/advconfig.rst
index 3a7bf2805..5f2175d2a 100644
--- a/docs/narr/advconfig.rst
+++ b/docs/narr/advconfig.rst
@@ -27,7 +27,7 @@ configured imperatively:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
@@ -38,7 +38,8 @@ configured imperatively:
config = Configurator()
config.add_view(hello_world)
app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
When you start this application, all will be OK. However, what happens if we
try to add another view to the configuration with the same set of
@@ -47,7 +48,7 @@ try to add another view to the configuration with the same set of
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
@@ -66,7 +67,8 @@ try to add another view to the configuration with the same set of
config.add_view(goodbye_world, name='hello')
app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
The application now has two conflicting view configuration statements. When
we try to start it again, it won't start. Instead, we'll receive a traceback
@@ -170,7 +172,7 @@ application that generates conflicts:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
@@ -189,7 +191,8 @@ application that generates conflicts:
config.add_view(goodbye_world, name='hello')
app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
We can prevent the two ``add_view`` calls from conflicting by issuing a call
to :meth:`~pyramid.config.Configurator.commit` between them:
@@ -197,7 +200,7 @@ to :meth:`~pyramid.config.Configurator.commit` between them:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
@@ -218,7 +221,8 @@ to :meth:`~pyramid.config.Configurator.commit` between them:
config.add_view(goodbye_world, name='hello')
app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
In the above example we've issued a call to
:meth:`~pyramid.config.Configurator.commit` between the two ``add_view``
diff --git a/docs/narr/configuration.rst b/docs/narr/configuration.rst
index 597d48b09..37122e382 100644
--- a/docs/narr/configuration.rst
+++ b/docs/narr/configuration.rst
@@ -36,7 +36,7 @@ applications, configured imperatively:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
@@ -46,8 +46,8 @@ applications, configured imperatively:
if __name__ == '__main__':
config = Configurator()
config.add_view(hello_world)
- app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
We won't talk much about what this application does yet. Just note that the
"configuration' statements take place underneath the ``if __name__ ==
@@ -105,7 +105,7 @@ in a package and its subpackages. For example:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.response import Response
from pyramid.view import view_config
@@ -118,7 +118,8 @@ in a package and its subpackages. For example:
config = Configurator()
config.scan()
app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
The scanning machinery imports each module and subpackage in a package or
module recursively, looking for special attributes attached to objects
diff --git a/docs/narr/firstapp.rst b/docs/narr/firstapp.rst
index c082f616b..922b0ea82 100644
--- a/docs/narr/firstapp.rst
+++ b/docs/narr/firstapp.rst
@@ -54,9 +54,8 @@ The script imports the :class:`~pyramid.config.Configurator` class from the
Like many other Python web frameworks, :app:`Pyramid` uses the :term:`WSGI`
protocol to connect an application and a web server together. The
-:mod:`paste.httpserver` server is used in this example as a WSGI server for
-convenience, as the ``paste`` package is a dependency of :app:`Pyramid`
-itself.
+:mod:`wsgiref` server is used in this example as a WSGI server for
+convenience, as it is shipped within the Python standard library.
The script also imports the :class:`pyramid.response.Response` class for
later use. An instance of this class will be used to create a web response.
@@ -205,14 +204,17 @@ WSGI Application Serving
:lines: 13
Finally, we actually serve the application to requestors by starting up a
-WSGI server. We happen to use the :func:`paste.httpserver.serve` WSGI server
-runner, passing it the ``app`` object (a :term:`router`) as the application
-we wish to serve. We also pass in an argument ``host='0.0.0.0'``, meaning
-"listen on all TCP interfaces." By default, the HTTP server listens
-only on the ``127.0.0.1`` interface, which is problematic if you're running
-the server on a remote system and you wish to access it with a web browser
-from a local system. We don't specify a TCP port number to listen on; this
-means we want to use the default TCP port, which is 8080.
+WSGI server. We happen to use the :mod:`wsgiref` ``make_server`` server
+maker for this purpose. We pass in as the first argument ``'0.0.0.0'``,
+which means "listen on all TCP interfaces." By default, the HTTP server
+listens only on the ``127.0.0.1`` interface, which is problematic if you're
+running the server on a remote system and you wish to access it with a web
+browser from a local system. We also specify a TCP port number to listen on,
+which is 8080, passing it as the second argument. The final argument ios ,
+passing it the ``app`` object (a :term:`router`), which is the the
+application we wish to serve. Finally, we call the server's
+``serve_forever`` method, which starts the main loop in which it will wait
+for requests from the outside world.
When this line is invoked, it causes the server to start listening on TCP
port 8080. The server will serve requests forever, or at least until we stop
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index a1ed6c7ff..fd6544416 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -812,7 +812,7 @@ performed, enabling you to set up the utility in advance:
.. code-block:: python
:linenos:
- from paste.httpserver import serve
+ from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from mypackage.interfaces import IMyUtility
@@ -831,7 +831,8 @@ performed, enabling you to set up the utility in advance:
config.registry.registerUtility(UtilityImplementation())
config.scan()
app = config.make_wsgi_app()
- serve(app, host='0.0.0.0')
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
For full details, please read the `Venusian documentation
<http://docs.repoze.org/venusian>`_.