summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2012-02-11 13:52:20 -0600
committerMichael Merickel <michael@merickel.org>2012-02-11 13:52:20 -0600
commitad3c25bac043e9d14ce8ffe1b03ae6d0e92b3b0e (patch)
tree445c6e074e1aaa19290c5cc1aae1c8a26e2cc0cd /docs
parente4b8fa632c5d2b020e168f4efe3d7c00049a279f (diff)
downloadpyramid-ad3c25bac043e9d14ce8ffe1b03ae6d0e92b3b0e.tar.gz
pyramid-ad3c25bac043e9d14ce8ffe1b03ae6d0e92b3b0e.tar.bz2
pyramid-ad3c25bac043e9d14ce8ffe1b03ae6d0e92b3b0e.zip
Updated the scripting example for more url control.
Diffstat (limited to 'docs')
-rw-r--r--docs/narr/commandline.rst22
1 files changed, 12 insertions, 10 deletions
diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst
index a1fcf12f5..95927cfca 100644
--- a/docs/narr/commandline.rst
+++ b/docs/narr/commandline.rst
@@ -606,19 +606,21 @@ Assuming that you have a route configured in your application like so:
config.add_route('verify', '/verify/{code}')
You need to inform the Pyramid environment that the WSGI application is
-handling requests from a certain base. For example, we want to mount our
-application at `example.com/prefix` and the generated URLs should use HTTPS.
-This can be done by mutating the request object:
+handling requests from a certain base. For example, we want to simulate
+mounting our application at `https://example.com/prefix`, to ensure that
+the generated URLs are correct for our deployment. This can be done by
+either mutating the resulting request object, or more simply by constructing
+the desired request and passing it into :func:`~pyramid.paster.bootstrap`:
.. code-block:: python
from pyramid.paster import bootstrap
- env = bootstrap('/path/to/my/development.ini#another')
- env['request'].host = 'example.com'
- env['request'].scheme = 'https'
- env['request'].script_name = '/prefix'
+ from pyramid.request import Request
+
+ request = Request.blank('/', base_url='https://example.com/prefix')
+ env = bootstrap('/path/to/my/development.ini#another', request=request)
print env['request'].application_url
- # will print 'https://example.com/prefix/another/url'
+ # will print 'https://example.com/prefix'
Now you can readily use Pyramid's APIs for generating URLs:
@@ -630,8 +632,8 @@ Now you can readily use Pyramid's APIs for generating URLs:
Cleanup
~~~~~~~
-When your scripting logic finishes, it's good manners (but not required) to
-call the ``closer`` callback:
+When your scripting logic finishes, it's good manners to call the ``closer``
+callback:
.. code-block:: python