2010-02-22 4 views
2

데코레이터 @not_authenticated에서 무슨 일이 벌어지고 있는지 이해하려고합니다. TraceRoute의 다음 단계는 'register'입니다. django_authopenid/views.py에도 있습니다. 그 이유는 어디에서도 등록이 보이지 않기 때문입니다.이 데코레이터가 어떻게 'register'메소드를 호출합니까?

'register'메서드는 어떻게 호출됩니까? U '/ 계정/레지스터 /'여기서

요청이다 :

<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {u'username': [u'BryanWheelock'], u'email': [u'[email protected]'], u'bnewaccount': [u'Signup']}>, COOKIES:{'__utma': '127460431.1218630960.1266769637.1266769637.1266864494.2', '__utmb': '127460431.3.10.1266864494', '__utmc': '127460431', '__utmz': '127460431.1266769637.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', 'sessionid': 'fb15ee538320170a22d3a3a324aad968'}, META:{'CONTENT_LENGTH': '74', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'DOCUMENT_ROOT': '/usr/local/apache2/htdocs', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'close', 'HTTP_COOKIE': '__utmz=127460431.1266769637.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=127460431.1218630960.1266769637.1266769637.1266864494.2; __utmc=127460431; __utmb=127460431.3.10.1266864494; sessionid=fb15ee538320170a22d3a3a324aad968', 'HTTP_HOST': 'workproject.com', 'HTTP_ORIGIN': 'http://workproject.com', 'HTTP_REFERER': 'http://workproject.com/account/signin/complete/?next=%2F&janrain_nonce=2010-02-22T18%3A49%3A53ZG2KXci&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2010-02-22T18%3A49%3A53Znxxxxxxxxxw&openid.return_to=http%3A%2F%2Fworkproject.com%2Faccount%2Fsignin%2Fcomplete%2F%3Fnext%3D%252F%26janrain_nonce%3D2010-02-22T18%253A49%253A53ZG2KXci&openid.assoc_handle=AOQobUepU4xs-kGg5LiyLzfN3RYv0I0Jocgjf_1odT4RR9zfMFpQVpMg&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle&openid.sig=Jf76i2RNhqpLTJMjeQ0nnQz6fgA%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItxxxxxxxxxs9CxHQ3PrHw_N5_3j1HM&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOaxxxxxxxxxxx4s9CxHQ3PrHw_N5_3j1HM', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.7 Safari/532.9', 'HTTP_X_FORWARDED_FOR': '96.8.31.235', 'PATH': '/usr/bin:/bin', 'PATH_INFO': u'/account/register/', 'PATH_TRANSLATED': '/home/spirituality/webapps/work/spirit_app.wsgi/account/register/', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '59956', 'REQUEST_METHOD': 'POST', 'REQUEST_URI': '/account/register/', 'SCRIPT_FILENAME': '/home/spirituality/webapps/spirituality/spirit_app.wsgi', 'SCRIPT_NAME': u'', 'SERVER_ADDR': '127.0.0.1', 'SERVER_ADMIN': '[no address given]', 'SERVER_NAME': 'workproject.com', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SIGNATURE': '', 'SERVER_SOFTWARE': 'Apache/2.2.12 (Unix) mod_wsgi/2.5 Python/2.5.4', 'mod_wsgi.application_group': 'www.workProject.com|', 'mod_wsgi.callable_object': 'application', 'mod_wsgi.listener_host': '', 'mod_wsgi.listener_port': '25931', 'mod_wsgi.process_group': '', 'mod_wsgi.reload_mechanism': '0', 'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (2, 5), 'wsgi.errors': <mod_wsgi.Log object at 0xb7ce0038>, 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0xb7e94b18>, 'wsgi.input': <mod_wsgi.Input object at 0x999cc78>, 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}> 
요청 찾고
def not_authenticated(func): 
    """ decorator that redirect user to next page if he is already logged.""" 
    def decorated(request, *args, **kwargs): 
     if request.user.is_authenticated(): 
      next = request.GET.get("next", "/") 
      return HttpResponseRedirect(next) 
     return func(request, *args, **kwargs) 
    return decorated 

@not_authenticated 
def signin(request,newquestion=False,newanswer=False): 
    """ 
    signin page. It manage the legacy authentification (user/password) 
    and authentification with openid. 

    url: /signin/ 

    template : authopenid/signin.htm 
    """ 
    request.encoding = 'UTF-8' 
    on_failure = signin_failure 
    next = clean_next(request.GET.get('next')) 

    form_signin = OpenidSigninForm(initial={'next':next}) 
    form_auth = OpenidAuthForm(initial={'next':next}) 

    if request.POST:  

     if 'bsignin' in request.POST.keys() or 'openid_username' in request.POST.keys(): 

      form_signin = OpenidSigninForm(request.POST) 
      if form_signin.is_valid(): 
       next = clean_next(form_signin.cleaned_data.get('next')) 
       sreg_req = sreg.SRegRequest(optional=['nickname', 'email']) 
       redirect_to = "%s%s?%s" % ( 
         get_url_host(request), 
         reverse('user_complete_signin'), 
         urllib.urlencode({'next':next}) 
       ) 
       return ask_openid(request, 
         form_signin.cleaned_data['openid_url'], 
         redirect_to, 
         on_failure=signin_failure, 
         sreg_request=sreg_req) 

     elif 'blogin' in request.POST.keys(): 
      # perform normal django authentification 
      form_auth = OpenidAuthForm(request.POST) 
      if form_auth.is_valid(): 
       user_ = form_auth.get_user() 
       login(request, user_) 
       next = clean_next(form_auth.cleaned_data.get('next')) 
       return HttpResponseRedirect(next) 

    question = None 
    if newquestion == True: 
     from forum.models import AnonymousQuestion as AQ 
     session_key = request.session.session_key 
     qlist = AQ.objects.filter(session_key=session_key).order_by('-added_at') 
     if len(qlist) > 0: 
      question = qlist[0] 
    answer = None 
    if newanswer == True: 
     from forum.models import AnonymousAnswer as AA 
     session_key = request.session.session_key 
     alist = AA.objects.filter(session_key=session_key).order_by('-added_at') 
     if len(alist) > 0: 
      answer = alist[0] 

    return render('authopenid/signin.html', { 
     'question':question, 
     'answer':answer, 
     'form1': form_auth, 
     'form2': form_signin, 
     'msg': request.GET.get('msg',''), 
     'sendpw_url': reverse('user_sendpw'), 
    }, context_instance=RequestContext(request)) 

, 그것은 계정/등록 보인다/'PATH_INFO'로 등록 방법을 참조하지 이 모든 것을 이해하려고하지 않고

답변

0

은 왜 삽입하지 않습니다

import pdb; pdb.set_trace() 

곳이 "등록"방법은 무엇입니까?

히트 "bt"

0
0

django_authopenid/views.py, 레지스터를 호출하는 것으로 보이는 부분을 통해 찾고 후 로그인 절차의 일부이다

이 등록 요청을 트리거 할 수있는 모든 방법을 특별히 알고 있지는 않지만 레지스터을 호출하는 부분입니다. 추적을 따라 ask_openid 코드를 읽으면 여기에 도착한 방법에 대한 단서를 얻을 수 있습니다.

관련 문제