mediagoblin.globals->mediagoblin.mg_globals

This commit is contained in:
Christopher Allan Webber 2011-06-12 17:27:37 -05:00
parent da579dec00
commit 6e7ce8d1af
14 changed files with 32 additions and 35 deletions

View File

@ -23,7 +23,7 @@ from webob import Request, exc
from mediagoblin import routing, util, storage, staticdirect from mediagoblin import routing, util, storage, staticdirect
from mediagoblin.db.open import setup_connection_and_db_from_config from mediagoblin.db.open import setup_connection_and_db_from_config
from mediagoblin.globals import setup_globals from mediagoblin.mg_globals import setup_globals
from mediagoblin.celery_setup import setup_celery_from_config from mediagoblin.celery_setup import setup_celery_from_config
from mediagoblin.workbench import WorkbenchManager, DEFAULT_WORKBENCH_DIR from mediagoblin.workbench import WorkbenchManager, DEFAULT_WORKBENCH_DIR

View File

@ -20,7 +20,7 @@ import random
import bcrypt import bcrypt
from mediagoblin.util import send_email, render_template from mediagoblin.util import send_email, render_template
from mediagoblin import globals as mgoblin_globals from mediagoblin import mg_globals
def bcrypt_check_password(raw_pass, stored_hash, extra_salt=None): def bcrypt_check_password(raw_pass, stored_hash, extra_salt=None):
@ -112,7 +112,7 @@ def send_verification_email(user, request):
# TODO: There is no error handling in place # TODO: There is no error handling in place
send_email( send_email(
mgoblin_globals.email_sender_address, mg_globals.email_sender_address,
[user['email']], [user['email']],
# TODO # TODO
# Due to the distributed nature of GNU MediaGoblin, we should # Due to the distributed nature of GNU MediaGoblin, we should

View File

@ -22,7 +22,7 @@ from paste.deploy.converters import asbool
from mediagoblin import storage from mediagoblin import storage
from mediagoblin.db.open import setup_connection_and_db_from_config from mediagoblin.db.open import setup_connection_and_db_from_config
from mediagoblin.celery_setup import setup_celery_from_config from mediagoblin.celery_setup import setup_celery_from_config
from mediagoblin.globals import setup_globals from mediagoblin.mg_globals import setup_globals
from mediagoblin.workbench import WorkbenchManager, DEFAULT_WORKBENCH_DIR from mediagoblin.workbench import WorkbenchManager, DEFAULT_WORKBENCH_DIR

View File

@ -16,8 +16,6 @@
from mongokit import DocumentMigration from mongokit import DocumentMigration
from mediagoblin import globals as mediagoblin_globals
class MediaEntryMigration(DocumentMigration): class MediaEntryMigration(DocumentMigration):
def allmigration01_uploader_to_reference(self): def allmigration01_uploader_to_reference(self):

View File

@ -20,7 +20,7 @@ from mongokit import Document, Set
from mediagoblin import util from mediagoblin import util
from mediagoblin.auth import lib as auth_lib from mediagoblin.auth import lib as auth_lib
from mediagoblin import globals as mediagoblin_globals from mediagoblin import mg_globals
from mediagoblin.db import migrations from mediagoblin.db import migrations
from mediagoblin.db.util import ObjectId from mediagoblin.db.util import ObjectId
@ -114,7 +114,7 @@ class MediaEntry(Document):
def generate_slug(self): def generate_slug(self):
self['slug'] = util.slugify(self['title']) self['slug'] = util.slugify(self['title'])
duplicate = mediagoblin_globals.database.media_entries.find_one( duplicate = mg_globals.database.media_entries.find_one(
{'slug': self['slug']}) {'slug': self['slug']})
if duplicate: if duplicate:

View File

@ -17,7 +17,6 @@
from mediagoblin.db import migrations from mediagoblin.db import migrations
from mediagoblin.gmg_commands import util as commands_util from mediagoblin.gmg_commands import util as commands_util
from mediagoblin import globals as mgoblin_globals
def migrate_parser_setup(subparser): def migrate_parser_setup(subparser):

View File

@ -17,7 +17,7 @@
import code import code
from mediagoblin import globals as mgoblin_globals from mediagoblin import mg_globals
from mediagoblin.gmg_commands import util as commands_util from mediagoblin.gmg_commands import util as commands_util
@ -35,7 +35,7 @@ GNU MediaGoblin shell!
---------------------- ----------------------
Available vars: Available vars:
- mgoblin_app: instantiated mediagoblin application - mgoblin_app: instantiated mediagoblin application
- mgoblin_globals: mediagoblin.globals - mg_globals: mediagoblin.globals
- db: database instance - db: database instance
""" """
@ -50,5 +50,5 @@ def shell(args):
banner=SHELL_BANNER, banner=SHELL_BANNER,
local={ local={
'mgoblin_app': mgoblin_app, 'mgoblin_app': mgoblin_app,
'mgoblin_globals': mgoblin_globals, 'mg_globals': mg_globals,
'db': mgoblin_globals.database}) 'db': mg_globals.database})

View File

@ -27,7 +27,7 @@ translations = gettext.find(
def setup_globals(**kwargs): def setup_globals(**kwargs):
from mediagoblin import globals as mg_globals from mediagoblin import mg_globals
for key, value in kwargs.iteritems(): for key, value in kwargs.iteritems():
setattr(mg_globals, key, value) setattr(mg_globals, key, value)

View File

@ -18,7 +18,7 @@ import Image
from mediagoblin.db.util import ObjectId from mediagoblin.db.util import ObjectId
from celery.task import task from celery.task import task
from mediagoblin import globals as mg_globals from mediagoblin import mg_globals
THUMB_SIZE = 200, 200 THUMB_SIZE = 200, 200

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from .. import globals from mediagoblin import mg_globals
def setup_package(): def setup_package():
@ -22,5 +22,5 @@ def setup_package():
def teardown_package(): def teardown_package():
print "Killing db ..." print "Killing db ..."
globals.db_connection.drop_database(globals.database.name) mg_globals.db_connection.drop_database(mg_globals.database.name)
print "... done" print "... done"

View File

@ -20,7 +20,7 @@ from nose.tools import assert_equal
from mediagoblin.auth import lib as auth_lib from mediagoblin.auth import lib as auth_lib
from mediagoblin.tests.tools import setup_fresh_app from mediagoblin.tests.tools import setup_fresh_app
from mediagoblin import globals as mgoblin_globals from mediagoblin import mg_globals
from mediagoblin import util from mediagoblin import util
@ -137,7 +137,7 @@ def test_register_views(test_app):
u'Passwords must match.'] u'Passwords must match.']
## At this point there should be no users in the database ;) ## At this point there should be no users in the database ;)
assert not mgoblin_globals.database.User.find().count() assert not mg_globals.database.User.find().count()
# Successful register # Successful register
# ------------------- # -------------------
@ -158,7 +158,7 @@ def test_register_views(test_app):
'mediagoblin/auth/register_success.html') 'mediagoblin/auth/register_success.html')
## Make sure user is in place ## Make sure user is in place
new_user = mgoblin_globals.database.User.find_one( new_user = mg_globals.database.User.find_one(
{'username': 'happygirl'}) {'username': 'happygirl'})
assert new_user assert new_user
assert new_user['status'] == u'needs_email_verification' assert new_user['status'] == u'needs_email_verification'
@ -191,7 +191,7 @@ def test_register_views(test_app):
context = util.TEMPLATE_TEST_CONTEXT[ context = util.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/verify_email.html'] 'mediagoblin/auth/verify_email.html']
assert context['verification_successful'] == False assert context['verification_successful'] == False
new_user = mgoblin_globals.database.User.find_one( new_user = mg_globals.database.User.find_one(
{'username': 'happygirl'}) {'username': 'happygirl'})
assert new_user assert new_user
assert new_user['status'] == u'needs_email_verification' assert new_user['status'] == u'needs_email_verification'
@ -203,7 +203,7 @@ def test_register_views(test_app):
context = util.TEMPLATE_TEST_CONTEXT[ context = util.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/verify_email.html'] 'mediagoblin/auth/verify_email.html']
assert context['verification_successful'] == True assert context['verification_successful'] == True
new_user = mgoblin_globals.database.User.find_one( new_user = mg_globals.database.User.find_one(
{'username': 'happygirl'}) {'username': 'happygirl'})
assert new_user assert new_user
assert new_user['status'] == u'active' assert new_user['status'] == u'active'

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin import globals as mg_globals from mediagoblin import mg_globals
def test_setup_globals(): def test_setup_globals():
mg_globals.setup_globals( mg_globals.setup_globals(

View File

@ -16,7 +16,7 @@
from mediagoblin.tests.tools import get_test_app from mediagoblin.tests.tools import get_test_app
from mediagoblin import globals as mgoblin_globals from mediagoblin import mg_globals
def test_get_test_app_wipes_db(): def test_get_test_app_wipes_db():
@ -24,15 +24,15 @@ def test_get_test_app_wipes_db():
Make sure we get a fresh database on every wipe :) Make sure we get a fresh database on every wipe :)
""" """
get_test_app() get_test_app()
assert mgoblin_globals.database.User.find().count() == 0 assert mg_globals.database.User.find().count() == 0
new_user = mgoblin_globals.database.User() new_user = mg_globals.database.User()
new_user['username'] = u'lolcat' new_user['username'] = u'lolcat'
new_user['email'] = u'lol@cats.example.org' new_user['email'] = u'lol@cats.example.org'
new_user['pw_hash'] = u'pretend_this_is_a_hash' new_user['pw_hash'] = u'pretend_this_is_a_hash'
new_user.save() new_user.save()
assert mgoblin_globals.database.User.find().count() == 1 assert mg_globals.database.User.find().count() == 1
get_test_app() get_test_app()
assert mgoblin_globals.database.User.find().count() == 0 assert mg_globals.database.User.find().count() == 0

View File

@ -31,7 +31,7 @@ import translitcodec
from paste.deploy.loadwsgi import NicerConfigParser from paste.deploy.loadwsgi import NicerConfigParser
from webob import Response, exc from webob import Response, exc
from mediagoblin import globals as mgoblin_globals from mediagoblin import mg_globals
from mediagoblin.db.util import ObjectId from mediagoblin.db.util import ObjectId
@ -102,8 +102,8 @@ def get_jinja_env(template_loader, locale):
extensions=['jinja2.ext.i18n']) extensions=['jinja2.ext.i18n'])
template_env.install_gettext_callables( template_env.install_gettext_callables(
mgoblin_globals.translations.gettext, mg_globals.translations.gettext,
mgoblin_globals.translations.ngettext) mg_globals.translations.ngettext)
if exists(locale): if exists(locale):
SETUP_JINJA_ENVS[locale] = template_env SETUP_JINJA_ENVS[locale] = template_env
@ -264,9 +264,9 @@ def send_email(from_addr, to_addrs, subject, message_body):
- message_body: email body text - message_body: email body text
""" """
# TODO: make a mock mhost if testing is enabled # TODO: make a mock mhost if testing is enabled
if TESTS_ENABLED or mgoblin_globals.email_debug_mode: if TESTS_ENABLED or mg_globals.email_debug_mode:
mhost = FakeMhost() mhost = FakeMhost()
elif not mgoblin_globals.email_debug_mode: elif not mg_globals.email_debug_mode:
mhost = smtplib.SMTP() mhost = smtplib.SMTP()
mhost.connect() mhost.connect()
@ -279,7 +279,7 @@ def send_email(from_addr, to_addrs, subject, message_body):
if TESTS_ENABLED: if TESTS_ENABLED:
EMAIL_TEST_INBOX.append(message) EMAIL_TEST_INBOX.append(message)
if getattr(mgoblin_globals, 'email_debug_mode', False): if getattr(mg_globals, 'email_debug_mode', False):
print u"===== Email =====" print u"===== Email ====="
print u"From address: %s" % message['From'] print u"From address: %s" % message['From']
print u"To addresses: %s" % message['To'] print u"To addresses: %s" % message['To']
@ -393,7 +393,7 @@ def setup_gettext(locale):
if exists(locale): if exists(locale):
SETUP_GETTEXTS[locale] = this_gettext SETUP_GETTEXTS[locale] = this_gettext
mgoblin_globals.setup_globals( mg_globals.setup_globals(
translations=this_gettext) translations=this_gettext)