2013-10-10 17 views
8

AuthAlreadyAssociatedのこの種の例外を処理するにはどうすればいいですか?Python Social AuthPython Social Authで例外を処理する方法

私が見つけたすべての回答はDjango Social Authですが、書かれて以来ずっと変わってきたようです。

答えて

12

それは私のために働く。

私は新しいミドルウェア

from social.apps.django_app.middleware import SocialAuthExceptionMiddleware 
from django.http import HttpResponse 
from social import exceptions as social_exceptions  

class MySocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware): 
    def process_exception(self, request, exception): 
     if hasattr(social_exceptions, exception.__class__.__name__): 
      return HttpResponse("catched: %s" % exception) 
     else: 
      raise exception 

を作成し、いくつかの場所で問題を考える場合

MIDDLEWARE_CLASSES = (
    ... 
    'path.to.MySocialAuthExceptionMiddleware', 
    ) 
+0

をsettings.pyのためにそれを追加しますが、それはここで発生します。.. –

関連する問題