from mediagoblin import routing, util, storage, staticdirect
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.workbench import WorkbenchManager, DEFAULT_WORKBENCH_DIR
import bcrypt
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):
# TODO: There is no error handling in place
send_email(
- mgoblin_globals.email_sender_address,
+ mg_globals.email_sender_address,
[user['email']],
# TODO
# Due to the distributed nature of GNU MediaGoblin, we should
from mediagoblin import storage
from mediagoblin.db.open import setup_connection_and_db_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 mongokit import DocumentMigration
-from mediagoblin import globals as mediagoblin_globals
-
class MediaEntryMigration(DocumentMigration):
def allmigration01_uploader_to_reference(self):
from mediagoblin import util
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.util import ObjectId
def generate_slug(self):
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']})
if duplicate:
from mediagoblin.db import migrations
from mediagoblin.gmg_commands import util as commands_util
-from mediagoblin import globals as mgoblin_globals
def migrate_parser_setup(subparser):
import code
-from mediagoblin import globals as mgoblin_globals
+from mediagoblin import mg_globals
from mediagoblin.gmg_commands import util as commands_util
----------------------
Available vars:
- mgoblin_app: instantiated mediagoblin application
- - mgoblin_globals: mediagoblin.globals
+ - mg_globals: mediagoblin.globals
- db: database instance
"""
banner=SHELL_BANNER,
local={
'mgoblin_app': mgoblin_app,
- 'mgoblin_globals': mgoblin_globals,
- 'db': mgoblin_globals.database})
+ 'mg_globals': mg_globals,
+ 'db': mg_globals.database})
def setup_globals(**kwargs):
- from mediagoblin import globals as mg_globals
+ from mediagoblin import mg_globals
for key, value in kwargs.iteritems():
setattr(mg_globals, key, value)
from mediagoblin.db.util import ObjectId
from celery.task import task
-from mediagoblin import globals as mg_globals
+from mediagoblin import mg_globals
THUMB_SIZE = 200, 200
# 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/>.
-from .. import globals
+from mediagoblin import mg_globals
def setup_package():
def teardown_package():
print "Killing db ..."
- globals.db_connection.drop_database(globals.database.name)
+ mg_globals.db_connection.drop_database(mg_globals.database.name)
print "... done"
from mediagoblin.auth import lib as auth_lib
from mediagoblin.tests.tools import setup_fresh_app
-from mediagoblin import globals as mgoblin_globals
+from mediagoblin import mg_globals
from mediagoblin import util
u'Passwords must match.']
## 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
# -------------------
'mediagoblin/auth/register_success.html')
## Make sure user is in place
- new_user = mgoblin_globals.database.User.find_one(
+ new_user = mg_globals.database.User.find_one(
{'username': 'happygirl'})
assert new_user
assert new_user['status'] == u'needs_email_verification'
context = util.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/verify_email.html']
assert context['verification_successful'] == False
- new_user = mgoblin_globals.database.User.find_one(
+ new_user = mg_globals.database.User.find_one(
{'username': 'happygirl'})
assert new_user
assert new_user['status'] == u'needs_email_verification'
context = util.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/verify_email.html']
assert context['verification_successful'] == True
- new_user = mgoblin_globals.database.User.find_one(
+ new_user = mg_globals.database.User.find_one(
{'username': 'happygirl'})
assert new_user
assert new_user['status'] == u'active'
# 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/>.
-from mediagoblin import globals as mg_globals
+from mediagoblin import mg_globals
def test_setup_globals():
mg_globals.setup_globals(
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():
Make sure we get a fresh database on every wipe :)
"""
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['email'] = u'lol@cats.example.org'
new_user['pw_hash'] = u'pretend_this_is_a_hash'
new_user.save()
- assert mgoblin_globals.database.User.find().count() == 1
+ assert mg_globals.database.User.find().count() == 1
get_test_app()
- assert mgoblin_globals.database.User.find().count() == 0
+ assert mg_globals.database.User.find().count() == 0
from paste.deploy.loadwsgi import NicerConfigParser
from webob import Response, exc
-from mediagoblin import globals as mgoblin_globals
+from mediagoblin import mg_globals
from mediagoblin.db.util import ObjectId
extensions=['jinja2.ext.i18n'])
template_env.install_gettext_callables(
- mgoblin_globals.translations.gettext,
- mgoblin_globals.translations.ngettext)
+ mg_globals.translations.gettext,
+ mg_globals.translations.ngettext)
if exists(locale):
SETUP_JINJA_ENVS[locale] = template_env
- message_body: email body text
"""
# 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()
- elif not mgoblin_globals.email_debug_mode:
+ elif not mg_globals.email_debug_mode:
mhost = smtplib.SMTP()
mhost.connect()
if TESTS_ENABLED:
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"From address: %s" % message['From']
print u"To addresses: %s" % message['To']
if exists(locale):
SETUP_GETTEXTS[locale] = this_gettext
- mgoblin_globals.setup_globals(
+ mg_globals.setup_globals(
translations=this_gettext)