From 815955a0c25522d9d22707ec5c3cdf978c24572a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 16:55:56 -0400 Subject: - New API methods in ``pyramid.session``: ``signed_serialize`` and ``signed_deserialize``. --- docs/api/session.rst | 5 +++++ pyramid/session.py | 51 +++++++++++++++++++++++++++++++++---------- pyramid/tests/test_session.py | 26 ++++++++++------------ 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/docs/api/session.rst b/docs/api/session.rst index daed9fc33..12b727183 100644 --- a/docs/api/session.rst +++ b/docs/api/session.rst @@ -7,3 +7,8 @@ .. autofunction:: InsecureCookieSessionFactoryConfig + .. autofunction:: signed_serialize + + .. autofunction:: signed_deserialize + + diff --git a/pyramid/session.py b/pyramid/session.py index 158468152..95d790a7b 100644 --- a/pyramid/session.py +++ b/pyramid/session.py @@ -110,9 +110,15 @@ def InsecureCookieSessionFactoryConfig( now = time.time() created = accessed = now new = True - cookieval = request.cookies.get(self._cookie_name) - value = deserialize(cookieval, self._secret) + value = None state = {} + cookieval = request.cookies.get(self._cookie_name) + if cookieval is not None: + try: + value = signed_deserialize(cookieval, self._secret) + except ValueError: + value = None + if value is not None: accessed, created, state = value new = False @@ -162,7 +168,7 @@ def InsecureCookieSessionFactoryConfig( exception = getattr(self.request, 'exception', None) if exception is not None: # dont set a cookie during exceptions return False - cookieval = serialize( + cookieval = signed_serialize( (self.accessed, self.created, dict(self)), self._secret ) if len(cookieval) > 4064: @@ -193,22 +199,43 @@ def InsecureCookieSessionFactoryConfig( return InsecureCookieSessionFactory -def serialize(data, secret): +def signed_serialize(data, secret): + """ Serialize any pickleable structure (``data``) and sign it + using the ``secret`` (must be a string). Return the + serialization, which includes the signature as its first 40 bytes. + The ``signed_deserialize`` method will deserialize such a value. + + This function is useful for creating signed cookies. For example: + + .. code-block:: python + + cookieval = signed_serialize({'a':1}, 'secret') + response.set_cookie('signed_cookie', cookieval) + """ pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) sig = hmac.new(secret, pickled, sha1).hexdigest() return sig + base64.standard_b64encode(pickled) -def deserialize(serialized, secret, hmac=hmac): - # hmac parameterized only for unit tests - if serialized is None: - return None +def signed_deserialize(serialized, secret, hmac=hmac): + """ Deserialize the value returned from ``signed_serialize``. If + the value cannot be deserialized for any reason, a + :exc:`ValueError` exception will be raised. + + This function is useful for deserializing a signed cookie value + created by ``signed_serialize``. For example: + .. code-block:: python + + cookieval = request.cookies['signed_cookie'] + data = signed_deserialize(cookieval, 'secret') + """ + # hmac parameterized only for unit tests try: input_sig, pickled = (serialized[:40], base64.standard_b64decode(serialized[40:])) - except (binascii.Error, TypeError): + except (binascii.Error, TypeError), e: # Badly formed data can make base64 die - return None + raise ValueError('Badly formed base64 data: %s' % e) sig = hmac.new(secret, pickled, sha1).hexdigest() @@ -216,7 +243,7 @@ def deserialize(serialized, secret, hmac=hmac): # have no idea what it means) if len(sig) != len(input_sig): - return None + raise ValueError('Wrong signature length') invalid_bits = 0 @@ -224,7 +251,7 @@ def deserialize(serialized, secret, hmac=hmac): invalid_bits += a != b if invalid_bits: - return None + raise ValueError('Invalid bits in signature') return pickle.loads(pickled) diff --git a/pyramid/tests/test_session.py b/pyramid/tests/test_session.py index 12f70bab9..07ca06c81 100644 --- a/pyramid/tests/test_session.py +++ b/pyramid/tests/test_session.py @@ -12,8 +12,8 @@ class TestInsecureCookieSession(unittest.TestCase): self.assertEqual(dict(session), {}) def _serialize(self, accessed, state, secret='secret'): - from pyramid.session import serialize - return serialize((accessed, accessed, state), secret) + from pyramid.session import signed_serialize + return signed_serialize((accessed, accessed, state), secret) def test_ctor_with_cookie_still_valid(self): import time @@ -172,22 +172,22 @@ def serialize(data, secret): sig = hmac.new(secret, pickled, sha1).hexdigest() return sig + base64.standard_b64encode(pickled) -class Test_serialize(unittest.TestCase): +class Test_signed_serialize(unittest.TestCase): def _callFUT(self, data, secret): - from pyramid.session import serialize - return serialize(data, secret) + from pyramid.session import signed_serialize + return signed_serialize(data, secret) def test_it(self): expected = serialize('123', 'secret') result = self._callFUT('123', 'secret') self.assertEqual(result, expected) -class Test_deserialize(unittest.TestCase): +class Test_signed_deserialize(unittest.TestCase): def _callFUT(self, serialized, secret, hmac=None): if hmac is None: import hmac - from pyramid.session import deserialize - return deserialize(serialized, secret, hmac=hmac) + from pyramid.session import signed_deserialize + return signed_deserialize(serialized, secret, hmac=hmac) def test_it(self): serialized = serialize('123', 'secret') @@ -196,8 +196,7 @@ class Test_deserialize(unittest.TestCase): def test_invalid_bits(self): serialized = serialize('123', 'secret') - result = self._callFUT(serialized, 'seekrit') - self.assertEqual(result, None) + self.assertRaises(ValueError, self._callFUT, serialized, 'seekrit') def test_invalid_len(self): class hmac(object): @@ -206,13 +205,12 @@ class Test_deserialize(unittest.TestCase): def hexdigest(self): return '1234' serialized = serialize('123', 'secret123') - result = self._callFUT(serialized, 'secret', hmac=hmac()) - self.assertEqual(result, None) + self.assertRaises(ValueError, self._callFUT, serialized, 'secret', + hmac=hmac()) def test_it_bad_encoding(self): serialized = 'bad' + serialize('123', 'secret') - result = self._callFUT(serialized, 'secret') - self.assertEqual(result, None) + self.assertRaises(ValueError, self._callFUT, serialized, 'secret') class DummySessionFactory(dict): -- cgit v1.2.3 From bba6d8bd106b39a617a637726cb2e0cc065cf5b8 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 16:56:28 -0400 Subject: gardening --- TODO.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index 463b0e1d5..131e20ac2 100644 --- a/TODO.txt +++ b/TODO.txt @@ -74,8 +74,6 @@ - Mako docs (in templating chapter). -- Paster template that has Mako. - - ``add_handler`` documentation. - ``handler`` ZCML directive. -- cgit v1.2.3 From 6a3184b3e02015ac3349d87c1f96a68827b47990 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 16:57:28 -0400 Subject: - The ``bfgshell`` paster command is now named ``pshell``. --- CHANGES.txt | 6 ++++++ docs/narr/project.rst | 40 ++++++++++++++++++++-------------------- docs/tutorials/catalog/index.rst | 6 +++--- docs/tutorials/zeo/index.rst | 4 ++-- pyramid/paster.py | 12 +++++++----- pyramid/tests/test_paster.py | 8 ++++---- setup.py | 2 +- 7 files changed, 43 insertions(+), 35 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8d3bfe3a0..a48e3556d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -42,6 +42,9 @@ Features (delta from BFG 1.3.X) paster templates. An import of ``pyramid.view.bfg_view``, however, will continue to work "forever". +- New API methods in ``pyramid.session``: ``signed_serialize`` and + ``signed_deserialize``. + Documentation (delta from BFG 1.3) ----------------------------------- @@ -81,3 +84,6 @@ Backwards Incompatibilities (with BFG 1.3.X) - The literal pattern ``{}`` is no longer permitted in route patterns (due to the addition of squiggly route pattern syntax support). + +- The ``bfgshell`` paster command is now named ``pshell``. + diff --git a/docs/narr/project.rst b/docs/narr/project.rst index f88496fcc..4e140709c 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -117,7 +117,7 @@ project we name ``MyProject``: $ bin/paster create -t pyramid_starter Selected and implied templates: - pyramid#bfg pyramid starter project + pyramid#pyramid_starter pyramid starter project Enter project name: MyProject Variables: @@ -223,18 +223,18 @@ the ``pyramid_starter`` template, a single sample test exists. .. index:: single: interactive shell single: IPython - single: paster bfgshell + single: paster pshell The Interactive Shell --------------------- Once you've installed your program for development using ``setup.py develop``, you can use an interactive Python shell to examine your -:mod:`pyramid` application :term:`model` and :term:`view` objects -from a Python prompt. To do so, use the ``paster`` shell command with -the ``bfgshell`` argument: +:mod:`pyramid` application :term:`model` and :term:`view` objects from +a Python prompt. To do so, use the ``paster`` shell command with the +``pshell`` argument: -The first argument to ``bfgshell`` is the path to your application's +The first argument to ``pshell`` is the path to your application's ``.ini`` file. The second is the section name inside the ``.ini`` file which points to your *application* as opposed to any other section within the ``.ini`` file. For example, if your application @@ -256,37 +256,37 @@ the name ``main`` as a section name: .. code-block:: text - [chrism@vitaminf bfgshellenv]$ ../bin/paster --plugin=pyramid bfgshell \ - MyProject.ini main + [chrism@vitaminf shellenv]$ ../bin/paster --plugin=pyramid \ + pshell MyProject.ini main 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 BFG app root object. + Type "help" for more information. "root" is the Pyramid app root object. >>> root .. note:: You *might* get away without passing - ``--plugin=pyramid`` to the bfgshell command. + ``--plugin=pyramid`` to the ``pshell`` command. If you have `IPython `_ installed in the interpreter you use to invoke the ``paster`` command, -the ``bfgshell`` command will use an IPython interactive shell instead +the ``pshell`` command will use an IPython interactive shell instead of a standard Python interpreter shell. If you don't want this to happen, even if you have IPython installed, you can pass the -``--disable-ipython`` flag to the ``bfgshell`` command to use a -standard Python interpreter shell unconditionally. +``--disable-ipython`` flag to the ``pshell`` command to use a standard +Python interpreter shell unconditionally. .. code-block:: text - [chrism@vitaminf bfgshellenv]$ ../bin/paster --plugin=pyramid bfgshell \ + [chrism@vitaminf shellenv]$ ../bin/paster --plugin=pyramid pshell \ --disable-ipython MyProject.ini main You should always use a section name argument that refers to the actual ``app`` section within the Paste configuration file that points -at your :mod:`pyramid` application *without any middleware -wrapping*. In particular, a section name is inappropriate as the -second argument to "bfgshell" if the configuration section it names is -a ``pipeline`` rather than an ``app``. For example, if you have the -following ``.ini`` file content: +at your :mod:`pyramid` application *without any middleware wrapping*. +In particular, a section name is inappropriate as the second argument +to ``pshell`` if the configuration section it names is a ``pipeline`` +rather than an ``app``. For example, if you have the following +``.ini`` file content: .. code-block:: ini :linenos: @@ -307,7 +307,7 @@ The command you use to invoke the interactive shell should be: .. code-block:: text - [chrism@vitaminf bfgshellenv]$ ../bin/paster --plugin=pyramid bfgshell \ + [chrism@vitaminf shellenv]$ ../bin/paster --plugin=pyramid pshell \ MyProject.ini myapp If you use ``main`` as the section name argument instead of ``myapp`` diff --git a/docs/tutorials/catalog/index.rst b/docs/tutorials/catalog/index.rst index 424286bd9..e4f6fe70e 100644 --- a/docs/tutorials/catalog/index.rst +++ b/docs/tutorials/catalog/index.rst @@ -78,12 +78,12 @@ want the application to be based on :term:`traversal`. return root['site'] #. We'll demonstrate how you might interact with a catalog from code - by manipulating the database directly using the ``bfgshell`` + by manipulating the database directly using the ``pshell`` command in a terminal window: .. code-block:: text - [chrism@snowpro sess]$ ../bin/paster --plugin=pyramid bfgshell \ + [chrism@snowpro sess]$ ../bin/paster --plugin=pyramid pshell \ myapp.ini myapp Python 2.5.4 (r254:67916, Sep 4 2009, 02:12:16) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin @@ -103,7 +103,7 @@ As you need them, add other indexes required by your application to the catalog by modifying the ``update_indexes`` method of the ``Site`` object. Whenever an index is added or removed, invoke the ``update_indexes`` method of the site (the root object) from a script -or from within a ``bfgshell`` session to update the set of indexes +or from within a ``pshell`` session to update the set of indexes used by your application. In :term:`view` code, you should be able to get a hold of the root diff --git a/docs/tutorials/zeo/index.rst b/docs/tutorials/zeo/index.rst index 1f6d1dac3..2e9d4aa2f 100644 --- a/docs/tutorials/zeo/index.rst +++ b/docs/tutorials/zeo/index.rst @@ -218,13 +218,13 @@ Running about the application has changed. #. You can manipulate the database directly (even when the - application's HTTP server is running) by using the ``bfgshell`` + application's HTTP server is running) by using the ``pshell`` command in a third terminal window: .. code-block:: text :linenos: - [chrism@snowpro sess]$ ../bin/paster --plugin=pyramid bfgshell \ + [chrism@snowpro sess]$ ../bin/paster --plugin=pyramid pshell \ myapp.ini myapp Python 2.5.4 (r254:67916, Sep 4 2009, 02:12:16) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin diff --git a/pyramid/paster.py b/pyramid/paster.py index 1a0e3f6cb..a1e895fcf 100644 --- a/pyramid/paster.py +++ b/pyramid/paster.py @@ -53,7 +53,7 @@ def get_app(config_file, name, loadapp=loadapp): return app _marker = object() -class BFGShellCommand(Command): +class PShellCommand(Command): """Open an interactive shell with a :mod:`pyramid` app loaded. This command accepts two positional arguments: @@ -66,11 +66,11 @@ class BFGShellCommand(Command): Example:: - $ paster bfgshell myapp.ini main + $ paster pshell myapp.ini main .. note:: You should use a ``section_name`` that refers to the actual ``app`` section in the config file that points at - your BFG app without any middleware wrapping, or this + your Pyramid app without any middleware wrapping, or this command will almost certainly fail. """ @@ -78,7 +78,7 @@ class BFGShellCommand(Command): min_args = 2 max_args = 2 - group_name = 'bfg' + group_name = 'pyramid' parser = Command.standard_parser(simulate=True) parser.add_option('-d', '--disable-ipython', @@ -104,7 +104,7 @@ class BFGShellCommand(Command): from IPython.Shell import IPShell except ImportError: #pragma no cover IPShell = None - cprt =('Type "help" for more information. "root" is the BFG app ' + cprt =('Type "help" for more information. "root" is the Pyramid app ' 'root object.') banner = "Python %s on %s\n%s" % (sys.version, sys.platform, cprt) config_file, section_name = self.args @@ -123,3 +123,5 @@ class BFGShellCommand(Command): self.interact[0](banner, local={'root':root}) finally: closer() + +BFGShellCommand = PShellCommand # b/w compat forever diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py index 69976e3b8..3c13a0ef0 100644 --- a/pyramid/tests/test_paster.py +++ b/pyramid/tests/test_paster.py @@ -1,12 +1,12 @@ import unittest -class TestBFGShellCommand(unittest.TestCase): +class TestPShellCommand(unittest.TestCase): def _getTargetClass(self): - from pyramid.paster import BFGShellCommand - return BFGShellCommand + from pyramid.paster import PShellCommand + return PShellCommand def _makeOne(self): - return self._getTargetClass()('bfgshell') + return self._getTargetClass()('pshell') def test_command_ipython_disabled(self): command = self._makeOne() diff --git a/setup.py b/setup.py index d7c549c03..b8330013e 100644 --- a/setup.py +++ b/setup.py @@ -86,7 +86,7 @@ setup(name='pyramid', pylons_minimal=pyramid.paster:PylonsMinimalProjectTemplate pylons_sqla=pyramid.paster:PylonsSQLAlchemyProjectTemplate [paste.paster_command] - pyramid_shell=pyramid.paster:BFGShellCommand + pshell=pyramid.paster:PShellCommand [console_scripts] bfg2pyramid = pyramid.fixers.fix_bfg_imports:main """ -- cgit v1.2.3 From fb52920afd55fc5221514502249d540c7e94e043 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 17:13:19 -0400 Subject: coverage --- pyramid/tests/test_session.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyramid/tests/test_session.py b/pyramid/tests/test_session.py index 07ca06c81..ff5c126cb 100644 --- a/pyramid/tests/test_session.py +++ b/pyramid/tests/test_session.py @@ -30,6 +30,13 @@ class TestInsecureCookieSession(unittest.TestCase): session = self._makeOne(request) self.assertEqual(dict(session), {}) + def test_ctor_with_bad_cookie(self): + request = testing.DummyRequest() + cookieval = 'abc' + request.cookies['session'] = cookieval + session = self._makeOne(request) + self.assertEqual(dict(session), {}) + def test_changed(self): request = testing.DummyRequest() session = self._makeOne(request) -- cgit v1.2.3 From cba2e1b549bf97333c155c4ca87860811dd4d2ef Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 17:15:01 -0400 Subject: bfg-> pyramid --- CHANGES.txt | 3 +++ TODO.txt | 16 ++++++++++++---- pyramid/configuration.py | 24 ++++++++++++------------ pyramid/events.py | 2 +- pyramid/interfaces.py | 2 +- pyramid/path.py | 4 ++-- pyramid/tests/test_authentication.py | 8 ++++---- pyramid/tests/test_configuration.py | 6 +++--- pyramid/tests/test_events.py | 3 ++- pyramid/tests/test_integration.py | 2 +- pyramid/tests/test_path.py | 14 +++++++------- pyramid/tests/test_zcml.py | 2 +- pyramid/view.py | 2 +- 13 files changed, 50 insertions(+), 38 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a48e3556d..dcfdbcaaa 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -87,3 +87,6 @@ Backwards Incompatibilities (with BFG 1.3.X) - The ``bfgshell`` paster command is now named ``pshell``. +- The Venusian "category" for all built-in Venusian decorators + (e.g. ``subscriber`` and ``view_config``/``bfg_view``) is now + ``pyramid`` instead of ``bfg``. diff --git a/TODO.txt b/TODO.txt index 131e20ac2..3cca270e3 100644 --- a/TODO.txt +++ b/TODO.txt @@ -66,8 +66,6 @@ - .flash API on session. -- Signed_signature method of the request and response from pylons2. - - Provide a webob.Response class facade for forward compat. - CRSF token machinery @@ -84,6 +82,16 @@ - Maybe make renderer globals lookup send an event? -- bfgshell - - ``docs`` directory for each paster template. + +- bfg.routes.matchdict and bfg.routes.route + +- repoze.bfg.auth_tkt + +- bfg_locale_name + +- bfg_localizer + +- __bfg_abspath__ + +- "BFG" in environ variables. diff --git a/pyramid/configuration.py b/pyramid/configuration.py index b877441ec..03966c3fd 100644 --- a/pyramid/configuration.py +++ b/pyramid/configuration.py @@ -1576,10 +1576,10 @@ class Configurator(object): :class:`pyramid.view.view_config``. If this is not desirable because the codebase has other Venusian-using decorators that aren't meant to be invoked during a particular scan, use - ``('bfg',)`` as a ``categories`` value to limit the execution + ``('pyramid',)`` as a ``categories`` value to limit the execution of decorator callbacks to only those registered by :mod:`pyramid` itself. Or pass a sequence of Venusian scan - categories as necessary (e.g. ``('bfg', 'myframework')``) to + categories as necessary (e.g. ``('pyramid', 'myframework')``) to limit the decorators called to the set of categories required. """ package = self.maybe_dotted(package) @@ -1917,7 +1917,7 @@ class Configurator(object): The ``name`` argument to ``add_static_view`` is usually a :term:`view name`. When this is the case, the :func:`pyramid.url.static_url` API will generate a URL - which points to a BFG view, which will serve up a set of + which points to a Pyramid view, which will serve up a set of resources that live in the package itself. For example: .. code-block:: python @@ -1935,7 +1935,7 @@ class Configurator(object): that represents a simple view name, as it is above, subsequent calls to :func:`pyramid.url.static_url` with paths that start with the ``path`` argument passed to ``add_static_view`` - will generate a URL something like ``http:///images/logo.png``, which will cause the ``logo.png`` file in the ``images`` subdirectory of the ``mypackage`` package to be served. @@ -2446,7 +2446,7 @@ def _map_view(view, attr=None, renderer_name=None, registry=None, if requestonly(view, attr): # its __init__ accepts only a single request argument, # instead of both context and request - def _bfg_class_requestonly_view(context, request): + def _class_requestonly_view(context, request): inst = view(request) if attr is None: response = inst() @@ -2459,10 +2459,10 @@ def _map_view(view, attr=None, renderer_name=None, registry=None, response = helper.render_to_response(response, system, request=request) return response - wrapped_view = _bfg_class_requestonly_view + wrapped_view = _class_requestonly_view else: # its __init__ accepts both context and request - def _bfg_class_view(context, request): + def _class_view(context, request): inst = view(context, request) if attr is None: response = inst() @@ -2475,12 +2475,12 @@ def _map_view(view, attr=None, renderer_name=None, registry=None, response = helper.render_to_response(response, system, request=request) return response - wrapped_view = _bfg_class_view + wrapped_view = _class_view elif requestonly(view, attr): # its __call__ accepts only a single request argument, # instead of both context and request - def _bfg_requestonly_view(context, request): + def _requestonly_view(context, request): if attr is None: response = view(request) else: @@ -2493,10 +2493,10 @@ def _map_view(view, attr=None, renderer_name=None, registry=None, response = helper.render_to_response(response, system, request=request) return response - wrapped_view = _bfg_requestonly_view + wrapped_view = _requestonly_view elif attr: - def _bfg_attr_view(context, request): + def _attr_view(context, request): response = getattr(view, attr)(context, request) if helper is not None: if not is_response(response): @@ -2505,7 +2505,7 @@ def _map_view(view, attr=None, renderer_name=None, registry=None, response = helper.render_to_response(response, system, request=request) return response - wrapped_view = _bfg_attr_view + wrapped_view = _attr_view elif helper is not None: def _rendered_view(context, request): diff --git a/pyramid/events.py b/pyramid/events.py index 78acce452..527707fb1 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -66,7 +66,7 @@ class subscriber(object): config.add_subscriber(wrapped, self.ifaces) def __call__(self, wrapped): - self.venusian.attach(wrapped, self.register, category='bfg') + self.venusian.attach(wrapped, self.register, category='pyramid') return wrapped class NewRequest(object): diff --git a/pyramid/interfaces.py b/pyramid/interfaces.py index 56486307a..1c7a8940c 100644 --- a/pyramid/interfaces.py +++ b/pyramid/interfaces.py @@ -244,7 +244,7 @@ class ISettings(Interface): interface.""" # this interface, even if it becomes unused within Pyramid, is -# imported by other packages (such as repoze.bfg.traversalwrapper) +# imported by other packages (such as traversalwrapper) class ILocation(Interface): """Objects that have a structural location""" __parent__ = Attribute("The parent in the location hierarchy") diff --git a/pyramid/path.py b/pyramid/path.py index b5850968f..2b557af5f 100644 --- a/pyramid/path.py +++ b/pyramid/path.py @@ -54,14 +54,14 @@ def caller_package(level=2, caller_module=caller_module): def package_path(package): # computing the abspath is actually kinda expensive so we memoize # the result - prefix = getattr(package, '__bfg_abspath__', None) + prefix = getattr(package, '__abspath__', None) if prefix is None: prefix = pkg_resources.resource_filename(package.__name__, '') # pkg_resources doesn't care whether we feed it a package # name or a module name within the package, the result # will be the same: a directory name to the package itself try: - package.__bfg_abspath__ = prefix + package.__abspath__ = prefix except: # this is only an optimization, ignore any error pass diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index 3bd1587f3..8bae18fba 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -460,23 +460,23 @@ class TestAuthTktCookieHelper(unittest.TestCase): def test_remember_path(self): plugin = self._makeOne('secret', include_ip=True, - path="/cgi-bin/bfg.cgi/") + path="/cgi-bin/app.cgi/") request = self._makeRequest() result = plugin.remember(request, 'other') self.assertEqual(len(result), 3) self.assertEqual(result[0][0], 'Set-Cookie') - self.failUnless(result[0][1].endswith('; Path=/cgi-bin/bfg.cgi/')) + self.failUnless(result[0][1].endswith('; Path=/cgi-bin/app.cgi/')) self.failUnless(result[0][1].startswith('auth_tkt=')) self.assertEqual(result[1][0], 'Set-Cookie') self.failUnless(result[1][1].endswith( - '; Path=/cgi-bin/bfg.cgi/; Domain=localhost')) + '; Path=/cgi-bin/app.cgi/; Domain=localhost')) self.failUnless(result[1][1].startswith('auth_tkt=')) self.assertEqual(result[2][0], 'Set-Cookie') self.failUnless(result[2][1].endswith( - '; Path=/cgi-bin/bfg.cgi/; Domain=.localhost')) + '; Path=/cgi-bin/app.cgi/; Domain=.localhost')) self.failUnless(result[2][1].startswith('auth_tkt=')) def test_remember_http_only(self): diff --git a/pyramid/tests/test_configuration.py b/pyramid/tests/test_configuration.py index 2ff6ed1e9..e24876744 100644 --- a/pyramid/tests/test_configuration.py +++ b/pyramid/tests/test_configuration.py @@ -129,9 +129,9 @@ class ConfiguratorTests(unittest.TestCase): def test_ctor_with_package_registry(self): import sys from pyramid.configuration import Configurator - bfg_pkg = sys.modules['pyramid'] - config = Configurator(package=bfg_pkg) - self.assertEqual(config.package, bfg_pkg) + pkg = sys.modules['pyramid'] + config = Configurator(package=pkg) + self.assertEqual(config.package, pkg) def test_ctor_noreg_custom_settings(self): from pyramid.interfaces import ISettings diff --git a/pyramid/tests/test_events.py b/pyramid/tests/test_events.py index 2930683db..7d763b3d6 100644 --- a/pyramid/tests/test_events.py +++ b/pyramid/tests/test_events.py @@ -151,7 +151,8 @@ class TestSubscriber(unittest.TestCase): dec.venusian = dummy_venusian def foo(): pass dec(foo) - self.assertEqual(dummy_venusian.attached, [(foo, dec.register, 'bfg')]) + self.assertEqual(dummy_venusian.attached, + [(foo, dec.register, 'pyramid')]) class DummyConfigurator(object): def __init__(self): diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 872f50cd4..e8d119e79 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -18,7 +18,7 @@ def wsgiapptest(environ, start_response): """ """ return '123' -class WGSIAppPlusBFGViewTests(unittest.TestCase): +class WGSIAppPlusViewConfigTests(unittest.TestCase): def test_it(self): from venusian import ATTACH_ATTR import types diff --git a/pyramid/tests/test_path.py b/pyramid/tests/test_path.py index 21e7bffe2..c097615af 100644 --- a/pyramid/tests/test_path.py +++ b/pyramid/tests/test_path.py @@ -3,8 +3,8 @@ import unittest class TestCallerPath(unittest.TestCase): def tearDown(self): from pyramid.tests import test_path - if hasattr(test_path, '__bfg_abspath__'): - del test_path.__bfg_abspath__ + if hasattr(test_path, '__abspath__'): + del test_path.__abspath__ def _callFUT(self, path, level=2): from pyramid.path import caller_path @@ -20,10 +20,10 @@ class TestCallerPath(unittest.TestCase): result = self._callFUT('a/b/c') self.assertEqual(result, os.path.join(here, 'a/b/c')) - def test_memoization_has_bfg_abspath(self): + def test_memoization_has_abspath(self): import os from pyramid.tests import test_path - test_path.__bfg_abspath__ = '/foo/bar' + test_path.__abspath__ = '/foo/bar' result = self._callFUT('a/b/c') self.assertEqual(result, os.path.join('/foo/bar', 'a/b/c')) @@ -33,7 +33,7 @@ class TestCallerPath(unittest.TestCase): from pyramid.tests import test_path result = self._callFUT('a/b/c') self.assertEqual(result, os.path.join(here, 'a/b/c')) - self.assertEqual(test_path.__bfg_abspath__, here) + self.assertEqual(test_path.__abspath__, here) class TestCallerModule(unittest.TestCase): def _callFUT(self, level=2): @@ -103,13 +103,13 @@ class TestPackagePath(unittest.TestCase): from pyramid.tests import test_path module = DummyPackageOrModule(test_path) self._callFUT(module) - self.assertEqual(module.__bfg_abspath__, module.package_path) + self.assertEqual(module.__abspath__, module.package_path) def test_memoization_fail(self): from pyramid.tests import test_path module = DummyPackageOrModule(test_path, raise_exc=TypeError) result = self._callFUT(module) - self.failIf(hasattr(module, '__bfg_abspath__')) + self.failIf(hasattr(module, '__abspath__')) self.assertEqual(result, module.package_path) class TestPackageOf(unittest.TestCase): diff --git a/pyramid/tests/test_zcml.py b/pyramid/tests/test_zcml.py index 789188666..b996dff53 100644 --- a/pyramid/tests/test_zcml.py +++ b/pyramid/tests/test_zcml.py @@ -472,7 +472,7 @@ class TestAuthTktAuthenticationPolicyDirective(unittest.TestCase): cookie_name='repoze.bfg.auth_tkt', secure=True, include_ip=True, timeout=100, reissue_time=500, http_only=True, - path="/cgi-bin/bfg.cgi/") + path="/cgi-bin/app.cgi/") class TestACLAuthorizationPolicyDirective(unittest.TestCase): def setUp(self): diff --git a/pyramid/view.py b/pyramid/view.py index bd9d52a24..68a8b92e7 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -408,7 +408,7 @@ class view_config(object): def callback(context, name, ob): context.config.add_view(view=ob, **settings) - info = self.venusian.attach(wrapped, callback, category='bfg') + info = self.venusian.attach(wrapped, callback, category='pyramid') if info.scope == 'class': # if the decorator was attached to a method in a class, or -- cgit v1.2.3 From e9a2ba347cec52cf9614f442978fe94ed6278b5c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 17:22:01 -0400 Subject: docs rendering --- docs/glossary.rst | 1 - docs/narr/views.rst | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/glossary.rst b/docs/glossary.rst index 9259fed0a..7320f5b4c 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -572,7 +572,6 @@ Glossary of code in a package. configuration decoration - Metadata implying one or more :term:`configuration declaration` invocations. Often set by configuration Python :term:`decorator` attributes, such as :class:`pyramid.view.view_config`, aka diff --git a/docs/narr/views.rst b/docs/narr/views.rst index 39115a493..37fb6562b 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -1502,7 +1502,7 @@ See :ref:`view_directive` for complete ZCML directive documentation. .. _mapping_views_using_a_decorator_section: View Configuration Using the ``@view_config`` Decorator -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For better locality of reference, you may use the :class:`pyramid.view.view_config` decorator to associate your view -- cgit v1.2.3 From 71ff1038f9ae7578e303ca9f657d34e4ee09305a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Oct 2010 19:02:18 -0400 Subject: bfg -> pyramid --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index eb236826b..59c0e0b0e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -160,7 +160,7 @@ html_last_updated_fmt = '%b %d, %Y' #html_file_suffix = '' # Output file base name for HTML help builder. -htmlhelp_basename = 'repozebfg' +htmlhelp_basename = 'pyramid' # Options for LaTeX output # ------------------------ @@ -174,7 +174,7 @@ latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ - ('latexindex', 'repozebfg.tex', + ('latexindex', 'pyramid.tex', 'The Pyramid Web Application Development Framework', 'Chris McDonough', 'manual'), ] -- cgit v1.2.3