# Path: spline/lib/helpers.py
# def static_uri(plugin_name, path, **url_kwargs):
# def sanitize_id(text):
# def h1(title, id=None, tag='h1', **attrs):
# def h2(title, id=None, **attrs):
# def timedelta_seconds(delta):
# def keysort(d, key):
# def get_translator(get_i18n, c):
# 
# 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/model/meta.py

# 
# Path: splinext/frontpage/sources.py
# def max_age_to_datetime(max_age):
#     """``max_age`` is specified in config as a number of seconds old.  This
#     function takes that number and returns a corresponding datetime object.
#     """
#     if max_age == None:
#         return None
# 
#     dt = datetime.datetime.now()
#     dt -= datetime.timedelta(seconds=int(max_age))
# 
#     return dt


import datetime
import logging
from pylons import config, request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from routes import request_config
from sqlalchemy.orm.exc import NoResultFound
from spline.lib import helpers as h
from spline.lib.base import BaseController, render
from spline.lib.plugin.load import run_hooks
from spline.model import meta
from splinext.frontpage.sources import max_age_to_datetime

        if times:
            last_seen_time = datetime.datetime.fromtimestamp(max(times))
            for update in updates:
                if update.time > last_seen_time:
                    c.last_seen_item = update
                else:
                    break

        # Save ~now~ as the last-seen time
        now = datetime.datetime.now().strftime('%s')
        if c.user:
            c.user.stash['frontpage-last-seen-time'] = now
            meta.Session.add(c.user)
        else:
            response.set_cookie('frontpage-last-seen-time', now)

        # Done!  Feed to template
        c.updates = updates

        # Hook for non-update interesting things to put on the front page.
        # This hook should return objects with a 'template' attribute, and
        # whatever else they need
        c.extras = run_hooks('frontpage_extras')

        ret = render('/index.mako')

        # Commit AFTER rendering the template!  Committing invalidates
        # everything in the session, undoing any eagerloading that may have
        # been done by sources

# Path: spline/lib/helpers.py
# def static_uri(plugin_name, path, **url_kwargs):
# def sanitize_id(text):
# def h1(title, id=None, tag='h1', **attrs):
# def h2(title, id=None, **attrs):
# def timedelta_seconds(delta):
# def keysort(d, key):
# def get_translator(get_i18n, c):
# 
# 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/model/meta.py

# 
# Path: splinext/frontpage/sources.py
# def max_age_to_datetime(max_age):
#     """``max_age`` is specified in config as a number of seconds old.  This
#     function takes that number and returns a corresponding datetime object.
#     """
#     if max_age == None:
#         return None
# 
#     dt = datetime.datetime.now()
#     dt -= datetime.timedelta(seconds=int(max_age))
# 
#     return dt


# Path: splinext/frontpage/controllers/frontpage.py
import datetime
import logging
from pylons import config, request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from routes import request_config
from sqlalchemy.orm.exc import NoResultFound
from spline.lib import helpers as h
from spline.lib.base import BaseController, render
from spline.lib.plugin.load import run_hooks
from spline.model import meta
from splinext.frontpage.sources import max_age_to_datetime


        if times:
            last_seen_time = datetime.datetime.fromtimestamp(max(times))
            for update in updates:
                if update.time > last_seen_time:
                    c.last_seen_item = update
                else:
                    break

        # Save ~now~ as the last-seen time
        now = datetime.datetime.now().strftime('%s')
        if c.user:
            c.user.stash['frontpage-last-seen-time'] = now
            meta.Session.add(c.user)
        else:
            response.set_cookie('frontpage-last-seen-time', now)

        # Done!  Feed to template
        c.updates = updates

        # Hook for non-update interesting things to put on the front page.
        # This hook should return objects with a 'template' attribute, and
        # whatever else they need
        c.extras = run_hooks('frontpage_extras')

        ret = render('/index.mako')

        # Commit AFTER rendering the template!  Committing invalidates
        # everything in the session, undoing any eagerloading that may have
        # been done by sources

        meta.Session.commit()