Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lazy translation to avoid import issues #1012

Merged
merged 1 commit into from Jun 19, 2017
Merged

Conversation

efischer19
Copy link
Contributor

@robrap, I believe this will fix the issues you pinged me about. Can you review when you get a chance?

If you need this to go out soon I can do an ORA release after we merge this in

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This isn't blocking me, so no rush. Also, it wasn't causing me a real issue except as a distraction because it looks like a big failure. I don't plan on testing that this resolves the issue until the fix comes through on master.

@efischer19
Copy link
Contributor Author

👍 sounds good. I'll merge once tests pass, but won't make a new ORA release just for this.

@robrap
Copy link
Contributor

robrap commented Jun 19, 2017

Understood. Thanks.

@efischer19 efischer19 merged commit b5f3333 into master Jun 19, 2017
@efischer19 efischer19 deleted the efischer/lazy_i18n branch June 19, 2017 21:09
@doctoryes
Copy link
Contributor

@efischer19 FYI - the issue that was fixed by this PR is causing a stack trace during LMS (and other) testing on my devstack. Here's the full error:

WARNING:xblock.plugin:Unable to load XBlock 'openassessment'
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/xblock/plugin.py", line 146, in load_classes
    yield (class_.name, cls._load_class_entry_point(class_))
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/xblock/plugin.py", line 75, in _load_class_entry_point
    class_ = entry_point.load()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2296, in load
    return self.resolve()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2302, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/openassessment/xblock/openassessmentblock.py", line 30, in <module>
    from openassessment.xblock.studio_mixin import StudioMixin
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/openassessment/xblock/studio_mixin.py", line 31, in <module>
    class StudioMixin(object):
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/openassessment/xblock/studio_mixin.py", line 48, in StudioMixin
    "required": _("Required"),
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 84, in ugettext
    return _trans.ugettext(message)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 330, in ugettext
    return do_translate(message, 'ugettext')
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 307, in do_translate
    _default = _default or translation(settings.LANGUAGE_CODE)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 209, in translation
    _translations[language] = DjangoTranslation(language)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 118, in __init__
    self._add_installed_apps_translations()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _add_installed_apps_translations
    "The translation infrastructure cannot be initialized before the "
AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

Any idea when the next ORA2 release containing this fix will happen?

@efischer19
Copy link
Contributor Author

@doctoryes I've been noticing that as well - I can just go ahead and push out a release tomorrow, it won't take too much effort.

I think there's going to be a similar release made for the similar "is not from an app in INSTALLED_APPS" warnings, but that fix is more non-trivial than this.

@doctoryes
Copy link
Contributor

Thanks. In Django 1.9, the code is not allowed to import models before the "application was loaded". The warnings are likely caused by that condition and will need a deeper fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants