Fix import errors

This commit is contained in:
Pierre Dulac 2013-03-03 01:09:39 +01:00
parent 30e3775b8b
commit 8845c0be88
3 changed files with 14 additions and 3 deletions

View File

@ -431,5 +431,12 @@ except ImportError:
# OAuth 2 support is optional
try:
import provider.oauth2 as oauth2_provider
# Hack to fix submodule import issues
submodules = ['backends', 'forms','managers','models','urls','views']
for s in submodules:
mod = __import__('provider.oauth2.%s.*' % s)
setattr(oauth2_provider, s, mod)
except ImportError:
oauth2_provider = None

View File

@ -106,7 +106,7 @@ try:
'provider',
'provider.oauth2',
)
except ImportError, inst:
except ImportError:
import logging
logging.warning("django-oauth2-provider is not install, some tests will be skipped")

View File

@ -46,6 +46,10 @@ urlpatterns = patterns('',
(r'^basic/$', MockView.as_view(authentication_classes=[BasicAuthentication])),
(r'^token/$', MockView.as_view(authentication_classes=[TokenAuthentication])),
(r'^auth-token/$', 'rest_framework.authtoken.views.obtain_auth_token'),
)
if oauth2_provider is not None:
urlpatterns += patterns('',
url(r'^oauth2/', include('provider.oauth2.urls', namespace = 'oauth2')),
url(r'^oauth2-test/$', MockView.as_view(authentication_classes=[OAuth2Authentication])),
)