2016-09-07 14:15:23 +02:00
|
|
|
import logging
|
|
|
|
|
2016-09-22 14:21:55 +02:00
|
|
|
import attract.shots
|
2016-09-08 12:41:49 +02:00
|
|
|
import flask
|
|
|
|
from werkzeug.local import LocalProxy
|
2016-08-31 11:30:44 +02:00
|
|
|
from pillar.extension import PillarExtension
|
2016-07-29 16:48:43 +02:00
|
|
|
|
2016-09-22 11:48:37 +02:00
|
|
|
import attract.tasks
|
2016-09-22 14:21:55 +02:00
|
|
|
import attract.shots
|
2016-09-08 12:41:49 +02:00
|
|
|
|
|
|
|
EXTENSION_NAME = 'attract'
|
2016-07-29 16:48:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
class AttractExtension(PillarExtension):
|
2016-08-31 16:00:40 +02:00
|
|
|
def __init__(self):
|
2016-09-07 14:15:23 +02:00
|
|
|
self._log = logging.getLogger('%s.AttractExtension' % __name__)
|
2016-09-22 11:48:37 +02:00
|
|
|
self.task_manager = attract.tasks.TaskManager()
|
2016-09-22 14:21:55 +02:00
|
|
|
self.shot_manager = attract.shots.ShotManager()
|
2016-08-31 16:00:40 +02:00
|
|
|
|
2016-07-29 16:48:43 +02:00
|
|
|
@property
|
|
|
|
def name(self):
|
2016-09-08 12:41:49 +02:00
|
|
|
return EXTENSION_NAME
|
2016-07-29 16:48:43 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
2016-08-31 11:32:17 +02:00
|
|
|
# Just so that it registers the management commands.
|
|
|
|
from . import cli
|
|
|
|
|
2016-07-29 16:48:43 +02:00
|
|
|
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
|
|
|
|
"""
|
2016-09-07 14:14:20 +02:00
|
|
|
|
|
|
|
return {}
|
2016-07-29 16:48:43 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2016-09-07 11:43:18 +02:00
|
|
|
|
2016-09-22 14:21:55 +02:00
|
|
|
from . import modules
|
2016-09-22 11:48:37 +02:00
|
|
|
import attract.tasks.routes
|
2016-09-22 14:21:55 +02:00
|
|
|
import attract.shots.routes
|
2016-09-07 11:43:18 +02:00
|
|
|
|
2016-09-21 10:49:34 +02:00
|
|
|
return [
|
|
|
|
modules.blueprint,
|
2016-09-22 11:48:37 +02:00
|
|
|
attract.tasks.routes.blueprint,
|
|
|
|
attract.tasks.routes.perproject_blueprint,
|
2016-09-22 14:21:55 +02:00
|
|
|
attract.shots.routes.blueprint,
|
|
|
|
attract.shots.routes.perproject_blueprint,
|
2016-09-21 10:49:34 +02:00
|
|
|
]
|
2016-08-31 16:00:40 +02:00
|
|
|
|
2016-09-06 18:46:28 +02:00
|
|
|
@property
|
|
|
|
def template_path(self):
|
|
|
|
import os.path
|
|
|
|
return os.path.join(os.path.dirname(__file__), 'templates')
|
|
|
|
|
2016-09-08 11:24:58 +02:00
|
|
|
@property
|
|
|
|
def static_path(self):
|
|
|
|
import os.path
|
|
|
|
return os.path.join(os.path.dirname(__file__), 'static')
|
|
|
|
|
2016-08-31 16:00:40 +02:00
|
|
|
def setup_app(self, app):
|
|
|
|
"""Connects Blinker signals."""
|
|
|
|
|
2016-09-22 14:09:19 +02:00
|
|
|
from . import subversion, tasks
|
2016-08-31 16:00:40 +02:00
|
|
|
|
|
|
|
subversion.task_logged.connect(self.task_manager.task_logged_in_svn)
|
2016-09-22 14:09:19 +02:00
|
|
|
tasks.setup_app(app)
|
2016-09-08 12:41:49 +02:00
|
|
|
|
|
|
|
|
2016-09-21 11:07:20 +02:00
|
|
|
def _get_current_attract():
|
|
|
|
"""Returns the Attract extension of the current application."""
|
2016-09-08 12:41:49 +02:00
|
|
|
|
2016-09-21 11:07:20 +02:00
|
|
|
return flask.current_app.pillar_extensions[EXTENSION_NAME]
|
2016-09-08 12:41:49 +02:00
|
|
|
|
|
|
|
|
2016-09-21 11:07:20 +02:00
|
|
|
current_attract = LocalProxy(_get_current_attract)
|
|
|
|
"""Attract extension of the current app."""
|