Example #1
0
def main (page='main', template='index.html', **kwargs):

    if not request.args.get ('silent', False):
        print >> sys.stderr, "Session: %r" % SessionAnchor (session)

    if 'reset' in request.args:
        director.reset (json=False)
    elif 'refresh' in request.args:
        director.refresh (json=False)

    @std_cache.memoize (900, name='views.main.cached_template', unless=app.is_dev)
    def cached_template (*args, **kwargs):
        return render_template (*args, **kwargs)

    canonical = get_canonical (page)
    debug = False if 'no-debug' in request.args else app.debug
    title = get_title (page)
    description = get_description (page)
    keywords = get_keywords (page)
    theme = request.args.get ('theme', 'blue')
    version = '.'.join (setup.version.split ('.')[:2])

    return cached_template (template, debug=debug, keywords=keywords,
        title=title, description=description, canonical=canonical, page=page,
        theme=theme, version=version, **kwargs)
Example #2
0
def main (page='main', template='index.html', **kwargs):

    if not request.args.get ('silent', False):
        print >> sys.stderr, "Session: %r" % SessionAnchor (session)

    if 'reset' in request.args:
        director.reset (json=False)
    elif 'refresh' in request.args:
        director.refresh (json=False)

    @std_cache.memoize (900, name='views.main.cached_template', unless=app.is_dev)
    def cached_template (*args, **kwargs):
        return render_template (*args, **kwargs)

    return cached_template (template,
        adsense=app.config['ADSENSE'],
        bbs=app.config['FORUM_URL'],
        canonical=get_canonical (page),
        debug=False if 'no-debug' in request.args else app.debug,
        description=get_description (page),
        keywords=get_keywords (page),
        theme=request.args.get ('theme', 'gray'),
        title=get_title (page),
        version='.'.join (setup.version.split ('.')[:2]),
        page=page, **kwargs)
Example #3
0
def main(page='main', template='index.html', **kwargs):

    if not request.args.get('silent', False):
        print >> sys.stderr, "Session: %r" % SessionAnchor(session)

    if 'reset' in request.args:
        director.reset(json=False)
    elif 'refresh' in request.args:
        director.refresh(json=False)

    @std_cache.memoize(900,
                       name='views.main.cached_template',
                       unless=app.is_dev)
    def cached_template(*args, **kwargs):
        return render_template(*args, **kwargs)

    return cached_template(
        template,
        adsense=app.config['ADSENSE'],
        bbs=app.config['FORUM_URL'],
        canonical=get_canonical(page),
        debug=False if 'no-debug' in request.args else app.debug,
        description=get_description(page),
        keywords=get_keywords(page),
        theme=request.args.get('theme', 'gray'),
        title=get_title(page),
        version='.'.join(setup.version.split('.')[:2]),
        page=page,
        **kwargs)
Example #4
0
def load_scenes():
    """
    Load all py files in scene directory
    """

    logger.info("Resetting Director")
    director.reset()

    _cwd = os.path.dirname(
        os.path.realpath(__file__)) if len(sys.argv) < 2 else sys.argv[1]
    scenename = os.path.join(_cwd, "scenes/")
    logger.info("Loading Scenes from %s", scenename)
    scenes = glob.glob(os.path.join(_cwd, "scenes/scene_*.py"))

    # Lets also reload contstants
    scenes.insert(0, os.path.join(_cwd, "scenes/constants.py"))

    for file_path in scenes:
        logger.info("Loading Scene %s", file_path)
        mod_name, file_ext = os.path.splitext(os.path.split(file_path)[-1])
        try:
            del sys.modules[mod_name]
        except KeyError:
            pass
        scene_mod = imp.load_source(mod_name, file_path)
Example #5
0
def main (page='home', template='index.html'):

    if not request.args.get ('silent', False):
        print >> sys.stderr, "Session: %r" % SessionAnchor (session)

    if 'reset' in request.args:
        director.reset (json=False)
    elif 'refresh' in request.args:
        director.refresh (json=False)
    else:
        director.setup (json=False)

    @cache.memoize (name='views.main.cached_template', unless=app.is_dev)
    def cached_template (template, page, debug):
        return render_template (template, page=page, debug=debug)

    return cached_template (template, page=page, debug=app.debug)
Example #6
0
def load_scenes():
    """
    Load all py files in scene directory
    """
    
    print("Resetting Director")
    director.reset()

    _cwd = os.path.dirname(os.path.realpath(__file__)) if len(sys.argv) < 2 else sys.argv[1]
    print "Loading Scenes from ", _cwd
    scenes = glob.glob(os.path.join(_cwd, "scene_*.py"))

    # Lets also reload contstants
    scenes.insert(0, os.path.join(_cwd, "constants.py"))

    for file_path in scenes:
        print("loading scene %s" % file_path)
        mod_name,file_ext = os.path.splitext(os.path.split(file_path)[-1])
        try:
            del sys.modules[mod_name]
        except KeyError:
            pass
        scene_mod = imp.load_source(mod_name, file_path)