2013-12-09 5 views
0

파이썬에서 GET 메서드를 처리 할 때 추가 인수를 전달하고 싶습니다.메서드에서 추가 인수 GET

class Lista: 
def GET(self): 
    try: 
     request = Request("") 
     response_body = urlopen(request).read() 
     decoded = json.loads(response_body) 
     return render.list(content = decoded, user = decoded[0]) 
    except(ValueError, KeyError, TypeError): 
     print "JSON format error" 

class Mail: 
    def GET(self): 
    request = Request("") 
    response_body = urlopen(request).read() 
    decoded = json.loads(response_body) 
    return render.mail(content = decoded, omail = decoded[0]) 

클래스 Lista는 요청 URL에서 개체 목록을 다운로드하고 HTML 파일 "목록"을 렌더링합니다. 렌더링 된 페이지에서 여러 사용자 중에서 선택할 수 있습니다. 나는 다음 클래스로 사용자가 선택한 것을 클릭하고 싶다.

도와주세요!

+0

들여 쓰기가 망가져 있습니다. GET()이 "Lista"의 멤버 인 경우 4 개의 공백만큼 들여 쓰기해야합니다. 그리고 당신은 어떤 종류의 웹 프레임 워크를 사용한다고 생각합니다. 귀하의 질문에 어떤 태그가 추가되었는지 알려주십시오. – guettli

+0

나는 웹 사이트를 사용한다;) – witek1902

답변

1

난 당신이 내가 오해하지 않는 한 같은 필요가 있다고 생각 :

class Lista: 
    def GET(self,x=None): 
     print x 
     try: 
      request = Request("") 
      response_body = urlopen(request).read() 
      decoded = json.loads(response_body) 
      return render.list(content = decoded, user = decoded[0]) 
     except(ValueError, KeyError, TypeError): 
      print "JSON format error" 

지금은 받아들이을 옵션 변수 x는 변수 x 그냥 빈 요청 정도

를 보내야하는 경우 None로 초기화된다
+0

나는 사용해야한다고 생각한다 : "http://example.com/msg?msgid=X" 하지만 나는 모른다.) – witek1902