summaryrefslogtreecommitdiff
path: root/repoze/bfg/scripting.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-11-04 05:39:49 +0000
committerChris McDonough <chrism@agendaless.com>2009-11-04 05:39:49 +0000
commit98ea383b580b77a2ff8cd81743ad0f0d90574547 (patch)
tree56d1d13ea1339fccffbcbba29224cd701ee6f6ee /repoze/bfg/scripting.py
parentc9b04a01e0b8f23b86d30e9ae1403a2964c34faa (diff)
downloadpyramid-98ea383b580b77a2ff8cd81743ad0f0d90574547.tar.gz
pyramid-98ea383b580b77a2ff8cd81743ad0f0d90574547.tar.bz2
pyramid-98ea383b580b77a2ff8cd81743ad0f0d90574547.zip
- The ``bfgshell`` command did not function properly; it was still
expecting to be able to call the root factory with a bare ``environ`` rather than a request object. - The ``repoze.bfg.scripting.get_app`` function now expects a ``request`` object as its second argument rather than an ``environ``.
Diffstat (limited to 'repoze/bfg/scripting.py')
-rw-r--r--repoze/bfg/scripting.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/repoze/bfg/scripting.py b/repoze/bfg/scripting.py
index 5399b7d77..f31db56fa 100644
--- a/repoze/bfg/scripting.py
+++ b/repoze/bfg/scripting.py
@@ -1,20 +1,21 @@
-def get_root(app, environ=None):
+from repoze.bfg.request import FakeRequest
+
+def get_root(app, request=None):
""" Return a tuple composed of ``(root, closer)`` when provided a
``repoze.bfg.router.Router`` instance as the ``app`` argument.
The ``root`` returned is the application root object. The
``closer`` returned is a callable (accepting no arguments) that
should be called when your scripting application is finished using
- the root. If ``environ`` is not None, it is used as the
- environment passed to the BFG application root factory. An empty
- environ is constructed and passed to the root factory if
- ``environ`` is None."""
+ the root. If ``request`` is not None, it is used as the request
+ passed to the BFG application root factory. A faux request is
+ constructed and passed to the root factory if ``request`` is None."""
+ if request is None:
+ request = FakeRequest({})
registry = app.registry
- threadlocals = {'registry':registry, 'request':None}
+ threadlocals = {'registry':registry, 'request':request}
app.threadlocal_manager.push(threadlocals)
- if environ is None:
- environ = {}
- def closer(environ=environ): # keep environ alive via this function default
+ def closer(request=request): # keep request alive via this function default
app.threadlocal_manager.pop()
- root = app.root_factory(environ)
+ root = app.root_factory(request)
return root, closer