mirror of
https://github.com/jazzband/django-authority.git
synced 2026-05-24 07:03:43 +00:00
Change module discovery to use the one from Django
This commit is contained in:
parent
14b92a0dcd
commit
c50368eb34
2 changed files with 4 additions and 26 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from django.utils.module_loading import autodiscover_modules
|
||||
|
||||
LOADING = False
|
||||
|
||||
|
||||
|
|
@ -11,5 +13,4 @@ def autodiscover():
|
|||
return
|
||||
LOADING = True
|
||||
|
||||
from authority import utils
|
||||
utils.autodiscover_modules()
|
||||
autodiscover_modules('permissions')
|
||||
|
|
|
|||
|
|
@ -1,26 +1,3 @@
|
|||
import sys
|
||||
|
||||
from authority.sites import site, get_check, get_choices_for, 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
|
||||
from authority.sites import site, get_check, get_choices_for, register, unregister # noqa
|
||||
|
|
|
|||
Loading…
Reference in a new issue