Permalink
Browse files

Using the .message attribute in Exception classes gives deprecation w…

…arnings in Python 2.6 (also, if you don't use the default .args attribute, then you should add a __str__ method to display the message in the stack trace). It's simpler to just use the BaseException mechanisms. The additional print statement is not necessary any more because the error message is now printed properly at the end of the stack trace.

--HG--
branch : 2.0
extra : rebase_source : 8f4081316a3dfff2902bdc450aed500f015612ed
  • Loading branch information...
1 parent ed9ed99 commit 0c5cdbc0e51c1ab695c531a69812cb8a8fb3c5d4 chrisz committed Aug 24, 2009
Showing with 6 additions and 8 deletions.
  1. +6 −8 tg/configuration.py
View
@@ -30,11 +30,10 @@
log = logging.getLogger(__name__)
+
class ConfigurationError(Exception):
"""Exception raised for errors in the configuration."""
- def __init__(self, message):
- self.message = message
class PylonsConfigWrapper(DictMixin):
"""Wrapper for the Pylons configuration.
@@ -462,16 +461,16 @@ def add_error_middleware(self, global_conf, app):
def add_auth_middleware(self, app, skip_authentication):
"""
Configure authentication and authorization.
-
+
:param app: The TG2 application.
:param skip_authentication: Should authentication be skipped if
explicitly requested? (used by repoze.who-testutil)
:type skip_authentication: bool
-
+
"""
from repoze.what.plugins.quickstart import setup_sql_auth
from repoze.what.plugins.pylonshq import booleanize_predicates
-
+
# Predicates booleanized:
booleanize_predicates()
@@ -488,8 +487,7 @@ def add_auth_middleware(self, app, skip_authentication):
msg = "base_config.sa_auth.cookie_secret is required " \
"you must define it in app_cfg.py or set " \
"sa_auth.cookie_secret in development.ini"
- print msg
- raise ConfigurationError(message=msg)
+ raise ConfigurationError(msg)
app = setup_sql_auth(app, skip_authentication=skip_authentication,
**auth_args)
return app
@@ -607,7 +605,7 @@ def make_base_app(global_conf, wrap_app=None, full_stack=True, **app_conf):
app = self.add_tosca_middleware(app)
if self.auth_backend == "sqlalchemy":
- # Skipping authentication if explicitly requested. Used by
+ # Skipping authentication if explicitly requested. Used by
# repoze.who-testutil:
skip_authentication = app_conf.get('skip_authentication', False)
app = self.add_auth_middleware(app, skip_authentication)

0 comments on commit 0c5cdbc

Please sign in to comment.