Commits

Thijs Triemstra committed 7503964
  • Participants
  • Parent commits c789741

Comments (0)

Files changed (6)

File pylonssecuredapp/config/environment.py

 from mako.lookup import TemplateLookup
 from pylons import config
 from pylons.error import handle_mako_error
+from pylons.configuration import PylonsConfig
 from sqlalchemy import engine_from_config
 
 import pylonssecuredapp.lib.app_globals as app_globals
 from pylonssecuredapp.model import init_model
 
 def load_environment(global_conf, app_conf):
-    """Configure the Pylons environment via the ``pylons.config``
+    """
+    Configure the Pylons environment via the ``pylons.config``
     object
     """
+    config = PylonsConfig()
+    
     # Pylons paths
     root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
     paths = dict(root=root,
     # Initialize config with the basic options
     config.init_app(global_conf, app_conf, package='pylonssecuredapp', paths=paths)
 
-    config['routes.map'] = make_map()
-    config['pylons.app_globals'] = app_globals.Globals()
+    config['routes.map'] = make_map(config)
+    config['pylons.app_globals'] = app_globals.Globals(config)
     config['pylons.h'] = pylonssecuredapp.lib.helpers
 
     # Create the Mako TemplateLookup, with the default auto-escaping
 
     # CONFIGURATION OPTIONS HERE (note: all config options will override
     # any Pylons config options)
+
+    return config

File pylonssecuredapp/config/middleware.py

 
     """
     # Configure the Pylons environment
-    load_environment(global_conf, app_conf)
+    config = load_environment(global_conf, app_conf)
 
     # The Pylons WSGI app
-    app = PylonsApp()
+    app = PylonsApp(config=config)
 
     # Routing/Session/Cache Middleware
     app = RoutesMiddleware(app, config['routes.map'])
     app = SessionMiddleware(app, config)
-    app = CacheMiddleware(app, config)
+    #app = CacheMiddleware(app, config)
 
     # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
 
         static_app = StaticURLParser(config['pylons.paths']['static_files'])
         app = Cascade([static_app, app])
 
+    app.config = config
+
     return app

File pylonssecuredapp/config/routing.py

 may take precedent over the more generic routes. For more information
 refer to the routes manual at http://routes.groovie.org/docs/
 """
-from pylons import config
+
 from routes import Mapper
 
-def make_map():
+def make_map(config):
     """Create, configure and return the routes Mapper"""
     map = Mapper(directory=config['pylons.paths']['controllers'],
                  always_scan=config['debug'])
     map.minimization = False
-
+    
     # The ErrorController route (handles 404/500 error pages); it should
     # likely stay at the top, ensuring it can always be resolved
     map.connect('/error/{action}', controller='error')

File pylonssecuredapp/lib/app_globals.py

 
     """
 
-    def __init__(self):
+    def __init__(self, config):
         """One instance of Globals is created during application
         initialization and is available during requests via the
         'app_globals' variable

File pylonssecuredapp/lib/auth.py

+import sys
 from logging import INFO
 
 from pylons import response
                                 logout_handler='/logout',
                                 post_login_url='/post_login',
                                 post_logout_url='/post_logout',
-                                log_level='info', 
+                                log_level='info', log_stream=sys.stdout,
                                 skip_authentication=skip_authentication)
     
     return securedapp

File pylonssecuredapp/websetup.py

 """Setup the PylonsSecuredApp application"""
 import logging
 
+import pylons.test
+
 from pylonssecuredapp.config.environment import load_environment
 
 from pylonssecuredapp.model import meta
 
 def setup_app(command, conf, vars):
     """Place any commands to setup pylonssecuredapp here"""
+    # Don't reload the app if it was loaded under the testing environment
+    if not pylons.test.pylonsapp:
+        load_environment(conf.global_conf, conf.local_conf)
+
     load_environment(conf.global_conf, conf.local_conf)
     setup_db(meta.engine)