mirror of
https://github.com/jazzband/django-authority.git
synced 2026-03-16 22:20:28 +00:00
Merge pull request #57 from epfl-idevelop/master
Change module discovery to use the one from Django
This commit is contained in:
commit
82d7feb47b
2 changed files with 2 additions and 28 deletions
|
|
@ -19,6 +19,5 @@ def autodiscover():
|
|||
return
|
||||
LOADING = True
|
||||
|
||||
from authority import utils
|
||||
|
||||
utils.autodiscover_modules()
|
||||
from django.utils.module_loading import autodiscover_modules
|
||||
autodiscover_modules('permissions')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import sys
|
||||
|
||||
from authority.sites import (
|
||||
site,
|
||||
get_check,
|
||||
|
|
@ -7,26 +5,3 @@ from authority.sites import (
|
|||
register,
|
||||
unregister,
|
||||
) # noqa
|
||||
|
||||
|
||||
def autodiscover_modules():
|
||||
"""
|
||||
Goes and imports the permissions submodule of every app in INSTALLED_APPS
|
||||
to make sure the permission set classes are registered correctly.
|
||||
"""
|
||||
import imp
|
||||
from django.conf import settings
|
||||
|
||||
for app in settings.INSTALLED_APPS:
|
||||
try:
|
||||
__import__(app)
|
||||
app_path = sys.modules[app].__path__
|
||||
except AttributeError:
|
||||
continue
|
||||
try:
|
||||
imp.find_module("permissions", app_path)
|
||||
except ImportError:
|
||||
continue
|
||||
__import__("%s.permissions" % app)
|
||||
app_path = sys.modules["%s.permissions" % app]
|
||||
LOADING = False
|
||||
|
|
|
|||
Loading…
Reference in a new issue