summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-12-16 19:03:00 -0500
committerChris McDonough <chrism@plope.com>2010-12-16 19:03:00 -0500
commitdc06b0b30c0508835022567cee40196d6d9cb984 (patch)
tree9f99b112874f3d42f2cb304fdadea666ce766a1b
parenta6a1508632a93f6c41e3d61007d5a3d891188bb6 (diff)
downloadpyramid-dc06b0b30c0508835022567cee40196d6d9cb984.tar.gz
pyramid-dc06b0b30c0508835022567cee40196d6d9cb984.tar.bz2
pyramid-dc06b0b30c0508835022567cee40196d6d9cb984.zip
- The name ``registry`` is now available in a ``pshell`` environment by
default. It is the application registry object. - Changed "Project" chapter slightly to expand on use of ``paster pshell``.
-rw-r--r--CHANGES.txt5
-rw-r--r--docs/narr/project.rst17
-rw-r--r--pyramid/paster.py5
-rw-r--r--pyramid/tests/test_paster.py9
4 files changed, 30 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index c3f7fb31f..33546e947 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -13,6 +13,9 @@ Features
- Added ``debug_routematch`` configuration setting that logs matched routes
(including the matchdict and predicates).
+- The name ``registry`` is now available in a ``pshell`` environment by
+ default. It is the application registry object.
+
Documentation
-------------
@@ -22,6 +25,8 @@ Documentation
- Added reference to ``BFG_DEBUG_ROUTEMATCH`` envvar and ``debug_routematch``
config file setting to the Environment narrative docs chapter.
+- Changed "Project" chapter slightly to expand on use of ``paster pshell``.
+
Paster Templates
----------------
diff --git a/docs/narr/project.rst b/docs/narr/project.rst
index f8a9017db..2b03f7373 100644
--- a/docs/narr/project.rst
+++ b/docs/narr/project.rst
@@ -287,9 +287,24 @@ the name ``MyProject`` as a section name:
[chrism@vitaminf shellenv]$ ../bin/paster pshell development.ini MyProject
Python 2.4.5 (#1, Aug 29 2008, 12:27:37)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
- Type "help" for more information. "root" is the Pyramid app root object.
+ Type "help" for more information. "root" is the Pyramid app root object,
+ "registry" is the Pyramid registry object.
>>> root
<myproject.models.MyModel object at 0x445270>
+ >>> registry
+ <Registry myproject>
+ >>> registry.settings['debug_notfound']
+ False
+ >>> from myproject.views import my_view
+ >>> from pyramid.request import Request
+ >>> r = Request.blank('/')
+ >>> my_view(r)
+ {'project': 'myproject'}
+
+Two names are made available to the pshell user as globals: ``root`` and
+``registry``. ``root`` is the the object returned by the default :term:`root
+factory` in your application. ``registry`` is the :term:`application
+registry` object (often accessed within view code as ``request.registry``).
If you have `IPython <http://en.wikipedia.org/wiki/IPython>`_
installed in the interpreter you use to invoke the ``paster`` command,
diff --git a/pyramid/paster.py b/pyramid/paster.py
index 0b8c21d4e..07f9ee458 100644
--- a/pyramid/paster.py
+++ b/pyramid/paster.py
@@ -115,7 +115,7 @@ class PShellCommand(Command):
except ImportError: #pragma no cover
IPShell = None
cprt =('Type "help" for more information. "root" is the Pyramid app '
- 'root object.')
+ 'root object, "registry" is the Pyramid registry object.')
banner = "Python %s on %s\n%s" % (sys.version, sys.platform, cprt)
config_file, section_name = self.args
self.logging_file_config(config_file)
@@ -130,7 +130,8 @@ class PShellCommand(Command):
closer()
else:
try:
- self.interact[0](banner, local={'root':root})
+ self.interact[0](banner,
+ local={'root':root,'registry':app.registry})
finally:
closer()
diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py
index 3c13a0ef0..41e6dc441 100644
--- a/pyramid/tests/test_paster.py
+++ b/pyramid/tests/test_paster.py
@@ -27,7 +27,8 @@ class TestPShellCommand(unittest.TestCase):
pushed = app.threadlocal_manager.pushed[0]
self.assertEqual(pushed['registry'], dummy_registry)
self.assertEqual(pushed['request'].registry, dummy_registry)
- self.assertEqual(interact.local, {'root':dummy_root})
+ self.assertEqual(interact.local, {'root':dummy_root,
+ 'registry':dummy_registry})
self.failUnless(interact.banner)
self.assertEqual(len(app.threadlocal_manager.popped), 1)
@@ -75,7 +76,8 @@ class TestPShellCommand(unittest.TestCase):
pushed = app.threadlocal_manager.pushed[0]
self.assertEqual(pushed['registry'], dummy_registry)
self.assertEqual(pushed['request'].registry, dummy_registry)
- self.assertEqual(interact.local, {'root':dummy_root})
+ self.assertEqual(interact.local, {'root':dummy_root,
+ 'registry':dummy_registry})
self.failUnless(interact.banner)
self.assertEqual(len(app.threadlocal_manager.popped), 1)
self.assertEqual(apped, [(('/foo/bar/myapp.ini', 'myapp'),
@@ -103,7 +105,8 @@ class TestPShellCommand(unittest.TestCase):
self.assertEqual(loadapp.section_name, 'myapp')
self.failUnless(loadapp.relative_to)
self.assertEqual(len(app.threadlocal_manager.pushed), 0)
- self.assertEqual(interact.local, {'root':root})
+ self.assertEqual(interact.local, {'root':root,
+ 'registry':dummy_registry})
self.failUnless(interact.banner)
self.assertEqual(apps, [app])