Page MenuHome

__init__.py
No OneTemporary

File Metadata

Created
Mon, Aug 26, 7:26 AM

__init__.py

import logging
import flask
from werkzeug.local import LocalProxy
from pillar.extension import PillarExtension
import attract.tasks
import attract.shot_manager
EXTENSION_NAME = 'attract'
class AttractExtension(PillarExtension):
def __init__(self):
self._log = logging.getLogger('%s.AttractExtension' % __name__)
self.task_manager = attract.tasks.TaskManager()
self.shot_manager = attract.shot_manager.ShotManager()
@property
def name(self):
return EXTENSION_NAME
def flask_config(self):
"""Returns extension-specific defaults for the Flask configuration.
Use this to set sensible default values for configuration settings
introduced by the extension.
:rtype: dict
"""
# Just so that it registers the management commands.
from . import cli
return {}
def eve_settings(self):
"""Returns extensions to the Eve settings.
Currently only the DOMAIN key is used to insert new resources into
Eve's configuration.
:rtype: dict
"""
return {}
def blueprints(self):
"""Returns the list of top-level blueprints for the extension.
These blueprints will be mounted at the url prefix given to
app.load_extension().
:rtype: list of flask.Blueprint objects.
"""
from . import modules, shots
import attract.tasks.routes
return [
modules.blueprint,
attract.tasks.routes.blueprint,
attract.tasks.routes.perproject_blueprint,
shots.blueprint,
shots.perproject_blueprint,
]
@property
def template_path(self):
import os.path
return os.path.join(os.path.dirname(__file__), 'templates')
@property
def static_path(self):
import os.path
return os.path.join(os.path.dirname(__file__), 'static')
def setup_app(self, app):
"""Connects Blinker signals."""
from . import subversion
subversion.task_logged.connect(self.task_manager.task_logged_in_svn)
def _get_current_attract():
"""Returns the Attract extension of the current application."""
return flask.current_app.pillar_extensions[EXTENSION_NAME]
current_attract = LocalProxy(_get_current_attract)
"""Attract extension of the current app."""

Event Timeline