Revision: 8114 Author: xqt Date: 2010-04-19 20:52:19 +0000 (Mon, 19 Apr 2010)
Log Message: ----------- build the cookie first before first login part
Modified Paths: -------------- trunk/pywikipedia/login.py
Modified: trunk/pywikipedia/login.py =================================================================== --- trunk/pywikipedia/login.py 2010-04-19 17:41:00 UTC (rev 8113) +++ trunk/pywikipedia/login.py 2010-04-19 20:52:19 UTC (rev 8114) @@ -168,32 +168,23 @@
if api: while True: + # build the cookie + L = {} + L["cookieprefix"] = None + index = self.site._userIndex(self.sysop) + if self.site._cookies[index]: + #if user is trying re-login, update the new information + self.site.updateCookies(L, self.sysop) + else: + # clean type login, setup the new cookies files. + self.site._setupCookies(L, self.sysop) response, data = query.GetData(predata, self.site, sysop=self.sysop, back_response = True) result = data['login']['result'] if result == "NeedToken": predata["lgtoken"] = data["login"]["token"] - # build the cookie (q&d-fix) - #### - Reat=re.compile(': (.*?)=(.*?);') - L = {} - L["cookieprefix"] = "pdcwiki" - #print '---------# data #---------' - #print data - #if got_token and got_user: - #process the basic information to Site() - index = self.site._userIndex(self.sysop) - #print index - #API result came back username, token and sessions. if ['lgtoken'] in data['login'].keys(): self.site._userName[index] = data['login']['lgusername'] self.site._token[index] = data['login']['lgtoken'] + "+\" - if self.site._cookies[index]: - #if user is trying re-login, update the new information - self.site.updateCookies(L, self.sysop) - else: - # clean type login, setup the new cookies files. - self.site._setupCookies(L, self.sysop) - #### continue break if result != "Success":