Permalink
Browse files

- The ``settings`` dictionary now raises a deprecation warning when you

  attempt to access its values via ``__getattr__`` instead of
  via ``__getitem__``.
  • Loading branch information...
1 parent 5c52dae commit b5ffe38cec2ac4bf8aa222204f32be9cca881dec @mcdonc mcdonc committed Aug 14, 2011
Showing with 35 additions and 19 deletions.
  1. +4 −0 CHANGES.txt
  2. +14 −16 TODO.txt
  3. +9 −3 pyramid/settings.py
  4. +8 −0 pyramid/tests/test_settings.py
View
@@ -81,6 +81,10 @@ Deprecations
them may print a deprecation warning. All scaffolds and tutorials have
been changed to use prefixed settings.
+- The ``settings`` dictionary now raises a deprecation warning when you
+ attempt to access its values via ``__getattr__`` instead of
+ via ``__getitem__``.
+
Backwards Incompatibilities
---------------------------
View
@@ -4,15 +4,18 @@ Pyramid TODOs
Should-Have
-----------
-- Debugging setting for detecting why authenticated_userid(request) might
- return None.
-
- Make it possible to use tween aliases in explicit tween config? If not,
the tween factories of all add-ons must be APIs.
+- Provide a way to set the authentication policy and the authorization policy
+ during a config.include (they are related, so just exposing the currently
+ underscored-private _set_auth* methods won't cut it).
+
- Come up with an analogue of repoze.zodbconn that doesn't require a closer
in the pipeline and use it in the ZODB scaffold and tutorial.
+- Merge Michael's route group work.
+
- Deprecate pyramid.security.view_execution_permitted (it only works for
traversal).
@@ -25,27 +28,22 @@ Should-Have
- "static_path" API (omit host and port).
-- Provide a way to set the authentication policy and the authorization policy
- during a config.include (they are related, so just exposing the currently
- underscored-private _set_auth* methods won't cut it).
-
-- Try to figure out a way to keep "settings" as the original dictionary
- passed to the Configurator instead of copying it.
-
-- Merge Michael's route group work.
-
- Kill off ``bfg.routes`` envvars in router.
-- Alias the stupid long default session factory name.
+- Debugging setting for detecting why authenticated_userid(request) might
+ return None.
-- Fix indirect circular import between router and config.
+
+Nice-to-Have
+------------
- Eliminate non-deployment-non-scaffold-related Paste dependencies:
``paste.urlparser.StaticURLParser``, ``paste.auth.auth_tkt`` (cutnpaste or
reimplement both).
-Nice-to-Have
-------------
+- Alias the stupid long default session factory name.
+
+- Fix indirect circular import between router and config.
- Add narrative docs for wsgiapp and wsgiapp2.
View
@@ -1,12 +1,12 @@
import os
from zope.deprecation import deprecated
+from zope.deprecation import deprecate
from zope.interface import implements
from pyramid.interfaces import ISettings
from pyramid.threadlocal import get_current_registry
-from pyramid.util import DottedNameResolver
class Settings(dict):
""" Deployment settings. Update application settings (usually
@@ -95,9 +95,15 @@ def __init__(self, d=None, _environ_=os.environ, **kw):
}
self.update(update)
-
+
+ dictlike = ('Use of the request as a dict-like object is deprecated as '
+ 'of Pyramid 1.1. Use dict-like methods of "request.environ" '
+ 'instead.')
+
+ @deprecate('Obtaining settings via attributes of the settings dictionary '
+ 'is deprecated as of Pyramid 1.2; use settings["foo"] instead '
+ 'of settings.foo')
def __getattr__(self, name):
- # backwards compatibility
try:
return self[name]
except KeyError:
@@ -2,6 +2,14 @@
from pyramid import testing
class TestSettings(unittest.TestCase):
+ def setUp(self):
+ from zope.deprecation import __show__
+ __show__.off()
+
+ def tearDown(self):
+ from zope.deprecation import __show__
+ __show__.on()
+
def _getTargetClass(self):
from pyramid.settings import Settings
return Settings

0 comments on commit b5ffe38

Please sign in to comment.