Sleepy / sleepy / templates / default_project / +package+ / config / environment.py_tmpl

from os.path import join, dirname, abspath

from mako.lookup import TemplateLookup
from pylons.configuration import PylonsConfig
from pylons.error import handle_mako_error

from sleepy.lonsies import data_path
from sleepy import resource

import {{ package }}.lib.app_globals as app_globals
import {{ package }}.lib.helpers
from {{ package }}.config.routing import make_map

def load_environment( global_conf,
                      app_conf ):
    config = PylonsConfig()
    root = dirname( dirname( abspath( __file__ )))
    paths = dict( root=root,
                  controllers=join( root,
                                    "controllers" ),
                  static_files=join( root,
                                     "public" ),
                  templates=[ join( root,
                                    "templates" ),
                              resource.templates_dir() ] )

    config.init_app( global_conf,
                     package="{{ package }}",
                     paths=paths )

    config[ "" ] = make_map( config )
    config[ "pylons.app_globals" ] = app_globals.Globals( config )
    config[ "pylons.h" ] = {{ package }}.lib.helpers
    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object( config[ "pylons.app_globals" ]
                                     .cache )
    ( config[ "pylons.app_globals" ]
            .mako_lookup ) = ( TemplateLookup( directories=paths[ "templates" ],
                                               module_directory=join( app_conf[ "cache_dir" ],
                                                                      "templates" ),
                                               cache_args=dict( manager=config
                                                                         [ "pylons.app_globals" ]
                                                                         .cache ),
                                               default_filters=[ "_raw",
                                                                 "escape" ],
                                               imports=[ "from sleepy.shorties import _raw",
                                                         "from webhelpers.html import escape" ] ))

    pylons.config.push_process_config( config )
    resource.init( data_path( "resources.yaml" ))

    return config
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.