# Path: spline/lib/base.py
# class SQLATimerProxy(object):
# class ResponseTimer(object):
# class BaseController(WSGIController):
# def _get_caller():
# def attach_timer(listener):
#     def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
#     def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
# def attach_query_log(listener):
#     def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
#     def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
#     def __init__(self):
#     def total_time(self):
#     def add_log(self, log):
#     def __before__(self, action, **params):
#     def __call__(self, environ, start_response):
#     def __after__(self, **params):
#     def cache_content(self, key, do_work, template):
#             def skip_cache(context, mako_def):
#         def cache_me(context, mako_def):
#             def generate_page():
# 
# Path: spline/lib/plugin/load.py
# def run_hooks(_spline_hook_name, *args, **kwargs):
#     """Runs the hooks registered for the given name, in priority order, passing
#     along all other arguments.
# 
#     If the hook is called outside the normal request cycle, such as with the
#     `routes_mapping` hook, then the `config` object must be explicitly passed
#     in.
# 
#     Current hooks:
# 
#     after_setup(config)
#         immediately following the Pylons environment setup
# 
#     routes_mapping(config, map)
#         near the end of Routes mapping, just before default routes are defined
# 
#     before_controller(action)
#         immediately before any controller is run
# 
#     after_controller()
#         immediately after any controller is run
#     """
# 
#     config = kwargs.get('config', pylons.config)
#     all_hooks = config['spline.plugins.hooks']
# 
#     if not _spline_hook_name in all_hooks:
#         # No hooks; bail
#         return []
#     hooks = all_hooks[_spline_hook_name]
# 
#     results = []
#     for priority in [1, 2, 3, 4, 5]:
#         if not priority in hooks:
#             # Nothing for this priority; bail
#             continue
# 
#         for function in hooks[priority]:
#             result = function(*args, **kwargs)
#             if result != None:
#                 results.append(result)
# 
#     return results


import datetime
import logging
from mako.template import Template
from pylons import cache, config, request, response, session, tmpl_context as c
from pylons.controllers.util import abort, redirect
from pylons.templating import pylons_globals
from spline.lib.base import BaseController, render
from spline.lib.plugin.load import run_hooks



log = logging.getLogger(__name__)

class MainController(BaseController):

    def index(self):
        """Blank front page.  Local plugin or the frontpage plugin can override
        it.
        """
        return render('/index.mako')


    def css(self):
        """Returns all the CSS in every plugin, concatenated."""
        # This solution sucks donkey balls, but it's marginally better than
        # loading every single stylesheet manually, so it stays until I have
        # a better idea
        response.headers['Content-type'] = 'text/css; charset=utf-8'

        stylesheets = []
        for css_file in config['spline.plugins.stylesheets']:

# Path: spline/lib/base.py
# class SQLATimerProxy(object):
# class ResponseTimer(object):
# class BaseController(WSGIController):
# def _get_caller():
# def attach_timer(listener):
#     def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
#     def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
# def attach_query_log(listener):
#     def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
#     def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
#     def __init__(self):
#     def total_time(self):
#     def add_log(self, log):
#     def __before__(self, action, **params):
#     def __call__(self, environ, start_response):
#     def __after__(self, **params):
#     def cache_content(self, key, do_work, template):
#             def skip_cache(context, mako_def):
#         def cache_me(context, mako_def):
#             def generate_page():
# 
# Path: spline/lib/plugin/load.py
# def run_hooks(_spline_hook_name, *args, **kwargs):
#     """Runs the hooks registered for the given name, in priority order, passing
#     along all other arguments.
# 
#     If the hook is called outside the normal request cycle, such as with the
#     `routes_mapping` hook, then the `config` object must be explicitly passed
#     in.
# 
#     Current hooks:
# 
#     after_setup(config)
#         immediately following the Pylons environment setup
# 
#     routes_mapping(config, map)
#         near the end of Routes mapping, just before default routes are defined
# 
#     before_controller(action)
#         immediately before any controller is run
# 
#     after_controller()
#         immediately after any controller is run
#     """
# 
#     config = kwargs.get('config', pylons.config)
#     all_hooks = config['spline.plugins.hooks']
# 
#     if not _spline_hook_name in all_hooks:
#         # No hooks; bail
#         return []
#     hooks = all_hooks[_spline_hook_name]
# 
#     results = []
#     for priority in [1, 2, 3, 4, 5]:
#         if not priority in hooks:
#             # Nothing for this priority; bail
#             continue
# 
#         for function in hooks[priority]:
#             result = function(*args, **kwargs)
#             if result != None:
#                 results.append(result)
# 
#     return results


# Path: spline/controllers/main.py
import datetime
import logging
from mako.template import Template
from pylons import cache, config, request, response, session, tmpl_context as c
from pylons.controllers.util import abort, redirect
from pylons.templating import pylons_globals
from spline.lib.base import BaseController, render
from spline.lib.plugin.load import run_hooks




log = logging.getLogger(__name__)

class MainController(BaseController):

    def index(self):
        """Blank front page.  Local plugin or the frontpage plugin can override
        it.
        """
        return render('/index.mako')


    def css(self):
        """Returns all the CSS in every plugin, concatenated."""
        # This solution sucks donkey balls, but it's marginally better than
        # loading every single stylesheet manually, so it stays until I have
        # a better idea
        response.headers['Content-type'] = 'text/css; charset=utf-8'

        stylesheets = []
        for css_file in config['spline.plugins.stylesheets']:

            stylesheets.append(render("/css/%s" % css_file))