Merge remote branch 'remotes/elrond/dev/init'
This commit is contained in:
commit
5d5eb6c331
@ -150,7 +150,7 @@ celeryd in another window.
|
||||
|
||||
Run::
|
||||
|
||||
CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_celery ./bin/celeryd
|
||||
CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery ./bin/celeryd
|
||||
|
||||
|
||||
Running the test suite
|
||||
|
@ -21,11 +21,12 @@ import routes
|
||||
from webob import Request, exc
|
||||
|
||||
from mediagoblin import routing, util, storage, staticdirect
|
||||
from mediagoblin.config import (
|
||||
from mediagoblin.init.config import (
|
||||
read_mediagoblin_config, generate_validation_report)
|
||||
from mediagoblin.db.open import setup_connection_and_db_from_config
|
||||
from mediagoblin.mg_globals import setup_globals
|
||||
from mediagoblin.celery_setup import setup_celery_from_config
|
||||
from mediagoblin.init.celery import setup_celery_from_config
|
||||
from mediagoblin.init import get_jinja_loader
|
||||
from mediagoblin.workbench import WorkbenchManager
|
||||
|
||||
|
||||
@ -71,7 +72,7 @@ class MediaGoblinApp(object):
|
||||
app_config)
|
||||
|
||||
# Get the template environment
|
||||
self.template_loader = util.get_jinja_loader(
|
||||
self.template_loader = get_jinja_loader(
|
||||
app_config.get('user_template_path'))
|
||||
|
||||
# Set up storage systems
|
||||
|
33
mediagoblin/init/__init__.py
Normal file
33
mediagoblin/init/__init__.py
Normal file
@ -0,0 +1,33 @@
|
||||
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||
# Copyright (C) 2011 Free Software Foundation, Inc
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import jinja2
|
||||
|
||||
|
||||
def get_jinja_loader(user_template_path=None):
|
||||
"""
|
||||
Set up the Jinja template loaders, possibly allowing for user
|
||||
overridden templates.
|
||||
|
||||
(In the future we may have another system for providing theming;
|
||||
for now this is good enough.)
|
||||
"""
|
||||
if user_template_path:
|
||||
return jinja2.ChoiceLoader(
|
||||
[jinja2.FileSystemLoader(user_template_path),
|
||||
jinja2.PackageLoader('mediagoblin', 'templates')])
|
||||
else:
|
||||
return jinja2.PackageLoader('mediagoblin', 'templates')
|
@ -20,7 +20,7 @@ import sys
|
||||
|
||||
MANDATORY_CELERY_IMPORTS = ['mediagoblin.process_media']
|
||||
|
||||
DEFAULT_SETTINGS_MODULE = 'mediagoblin.celery_setup.dummy_settings_module'
|
||||
DEFAULT_SETTINGS_MODULE = 'mediagoblin.init.celery.dummy_settings_module'
|
||||
|
||||
|
||||
def setup_celery_from_config(app_config, global_config,
|
@ -17,7 +17,7 @@
|
||||
import os
|
||||
|
||||
from mediagoblin import app, mg_globals
|
||||
from mediagoblin.celery_setup import setup_celery_from_config
|
||||
from mediagoblin.init.celery import setup_celery_from_config
|
||||
|
||||
|
||||
OUR_MODULENAME = __name__
|
@ -17,7 +17,7 @@
|
||||
import os
|
||||
|
||||
from mediagoblin.tests.tools import TEST_APP_CONFIG
|
||||
from mediagoblin.celery_setup.from_celery import setup_self
|
||||
from mediagoblin.init.celery.from_celery import setup_self
|
||||
|
||||
|
||||
OUR_MODULENAME = __name__
|
@ -16,8 +16,8 @@
|
||||
|
||||
import pkg_resources
|
||||
|
||||
from mediagoblin import celery_setup
|
||||
from mediagoblin.config import read_mediagoblin_config
|
||||
from mediagoblin.init import celery as celery_setup
|
||||
from mediagoblin.init.config import read_mediagoblin_config
|
||||
|
||||
|
||||
TEST_CELERY_CONF_NOSPECIALDB = pkg_resources.resource_filename(
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pkg_resources
|
||||
|
||||
from mediagoblin import config
|
||||
from mediagoblin.init import config
|
||||
|
||||
|
||||
CARROT_CONF_GOOD = pkg_resources.resource_filename(
|
||||
|
@ -8,7 +8,7 @@ email_debug_mode = true
|
||||
db_name = __mediagoblin_tests__
|
||||
|
||||
# Celery shouldn't be set up by the application as it's setup via
|
||||
# mediagoblin.celery_setup.from_celery
|
||||
# mediagoblin.init.celery.from_celery
|
||||
celery_setup_elsewhere = true
|
||||
|
||||
[celery]
|
||||
|
@ -22,7 +22,7 @@ from paste.deploy import loadapp
|
||||
from webtest import TestApp
|
||||
|
||||
from mediagoblin import util
|
||||
from mediagoblin.config import read_mediagoblin_config
|
||||
from mediagoblin.init.config import read_mediagoblin_config
|
||||
from mediagoblin.decorators import _make_safe
|
||||
from mediagoblin.db.open import setup_connection_and_db_from_config
|
||||
|
||||
@ -42,8 +42,8 @@ USER_DEV_DIRECTORIES_TO_SETUP = [
|
||||
|
||||
BAD_CELERY_MESSAGE = """\
|
||||
Sorry, you *absolutely* must run nosetests with the
|
||||
mediagoblin.celery_setup.from_tests module. Like so:
|
||||
$ CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests ./bin/nosetests"""
|
||||
mediagoblin.init.celery.from_tests module. Like so:
|
||||
$ CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests ./bin/nosetests"""
|
||||
|
||||
|
||||
class BadCeleryEnviron(Exception): pass
|
||||
@ -51,7 +51,7 @@ class BadCeleryEnviron(Exception): pass
|
||||
|
||||
def suicide_if_bad_celery_environ():
|
||||
if not os.environ.get('CELERY_CONFIG_MODULE') == \
|
||||
'mediagoblin.celery_setup.from_tests':
|
||||
'mediagoblin.init.celery.from_tests':
|
||||
raise BadCeleryEnviron(BAD_CELERY_MESSAGE)
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ def get_test_app(dump_old_app=True):
|
||||
suicide_if_bad_celery_environ()
|
||||
|
||||
# Leave this imported as it sets up celery.
|
||||
from mediagoblin.celery_setup import from_tests
|
||||
from mediagoblin.init.celery import from_tests
|
||||
|
||||
global MGOBLIN_APP
|
||||
|
||||
|
@ -64,22 +64,6 @@ def clear_test_buckets():
|
||||
clear_test_template_context()
|
||||
|
||||
|
||||
def get_jinja_loader(user_template_path=None):
|
||||
"""
|
||||
Set up the Jinja template loaders, possibly allowing for user
|
||||
overridden templates.
|
||||
|
||||
(In the future we may have another system for providing theming;
|
||||
for now this is good enough.)
|
||||
"""
|
||||
if user_template_path:
|
||||
return jinja2.ChoiceLoader(
|
||||
[jinja2.FileSystemLoader(user_template_path),
|
||||
jinja2.PackageLoader('mediagoblin', 'templates')])
|
||||
else:
|
||||
return jinja2.PackageLoader('mediagoblin', 'templates')
|
||||
|
||||
|
||||
SETUP_JINJA_ENVS = {}
|
||||
|
||||
|
||||
|
@ -27,4 +27,4 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests $NOSETESTS $@
|
||||
CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests $NOSETESTS $@
|
||||
|
Loading…
x
Reference in New Issue
Block a user