summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Duncan <casey.duncan@gmail.com>2010-12-14 20:52:14 -0700
committerCasey Duncan <casey.duncan@gmail.com>2010-12-14 20:52:14 -0700
commit171c2dca2776e9b9642bcf8b0d4a30ba97ab5724 (patch)
treefbad8fe91421e21bcb082d9c9a1fd93605a25113
parent373b79f0a0384eaf56126bfbf5d322f3d63ffdd4 (diff)
parentb07059b75021e2dc4f55357dd6b454c4951b3b9c (diff)
downloadpyramid-171c2dca2776e9b9642bcf8b0d4a30ba97ab5724.tar.gz
pyramid-171c2dca2776e9b9642bcf8b0d4a30ba97ab5724.tar.bz2
pyramid-171c2dca2776e9b9642bcf8b0d4a30ba97ab5724.zip
Merge https://github.com/Pylons/pyramid
-rw-r--r--CHANGES.txt6
-rw-r--r--TODO.txt3
-rw-r--r--pyramid/path.py4
-rw-r--r--pyramid/tests/test_path.py16
4 files changed, 25 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index dfa7bf7fc..be2bd2b5f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -48,6 +48,12 @@ Dependencies
Bug Fixes
---------
+- When creating a Configurator from within a ``paster pshell`` session, you
+ were required to pass a ``package`` argument although ``package`` is not
+ actually required. If you didn't pass ``package``, you would receive an
+ error something like ``KeyError: '__name__'`` emanating from the
+ ``pyramid.path.caller_module`` function. This has now been fixed.
+
- The ``pyramid_routesalchemy`` paster template's unit tests failed
(``AssertionError: 'SomeProject' != 'someproject'``). This is fixed.
diff --git a/TODO.txt b/TODO.txt
index f8fe6d07c..668cf0840 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -18,6 +18,9 @@ Must-Have (before 1.0)
- Use ``@register_view`` instead of ``@view_config`` and change view docs to
use "view registration" instead of "view configuration".
+- Change references to "model" to references to "resource" in all docs (and
+ alias model_url to resource_url, etc).
+
Should-Have
-----------
diff --git a/pyramid/path.py b/pyramid/path.py
index 10647c073..9c7be4c57 100644
--- a/pyramid/path.py
+++ b/pyramid/path.py
@@ -14,9 +14,9 @@ def caller_path(path, level=2):
path = os.path.join(prefix, path)
return path
-def caller_module(level=2):
+def caller_module(level=2, sys=sys):
module_globals = sys._getframe(level).f_globals
- module_name = module_globals['__name__']
+ module_name = module_globals.get('__name__') or '__main__'
module = sys.modules[module_name]
return module
diff --git a/pyramid/tests/test_path.py b/pyramid/tests/test_path.py
index c097615af..5619aafa1 100644
--- a/pyramid/tests/test_path.py
+++ b/pyramid/tests/test_path.py
@@ -36,9 +36,9 @@ class TestCallerPath(unittest.TestCase):
self.assertEqual(test_path.__abspath__, here)
class TestCallerModule(unittest.TestCase):
- def _callFUT(self, level=2):
+ def _callFUT(self, *arg, **kw):
from pyramid.path import caller_module
- return caller_module(level)
+ return caller_module(*arg, **kw)
def test_it_level_1(self):
from pyramid.tests import test_path
@@ -55,6 +55,18 @@ class TestCallerModule(unittest.TestCase):
result = self._callFUT(3)
self.failIfEqual(result, test_path)
+ def test_it_no___name__(self):
+ class DummyFrame(object):
+ f_globals = {}
+ class DummySys(object):
+ def _getframe(self, level):
+ return DummyFrame()
+ modules = {'__main__':'main'}
+ dummy_sys = DummySys()
+ result = self._callFUT(3, sys=dummy_sys)
+ self.assertEqual(result, 'main')
+
+
class TestCallerPackage(unittest.TestCase):
def _callFUT(self, *arg, **kw):
from pyramid.path import caller_package