rename decorator
This commit is contained in:
parent
44221c4c9e
commit
20850bc1a1
1 changed files with 3 additions and 8 deletions
|
|
@ -187,7 +187,7 @@ class BaseBrowser(mechanize.Browser):
|
||||||
def keepalive(self):
|
def keepalive(self):
|
||||||
self.home()
|
self.home()
|
||||||
|
|
||||||
def change_location(func):
|
def check_location(func):
|
||||||
def inner(self, *args, **kwargs):
|
def inner(self, *args, **kwargs):
|
||||||
if args and isinstance(args[0], (str,unicode)) and args[0][0] == '/' and \
|
if args and isinstance(args[0], (str,unicode)) and args[0][0] == '/' and \
|
||||||
(not self.request or self.request.host != self.DOMAIN):
|
(not self.request or self.request.host != self.DOMAIN):
|
||||||
|
|
@ -196,7 +196,7 @@ class BaseBrowser(mechanize.Browser):
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
@change_location
|
@check_location
|
||||||
def openurl(self, *args, **kwargs):
|
def openurl(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Open an URL but do not create a Page object.
|
Open an URL but do not create a Page object.
|
||||||
|
|
@ -238,7 +238,7 @@ class BaseBrowser(mechanize.Browser):
|
||||||
self.home()
|
self.home()
|
||||||
raise BrowserUnavailable()
|
raise BrowserUnavailable()
|
||||||
|
|
||||||
@change_location
|
@check_location
|
||||||
def location(self, *args, **kwargs):
|
def location(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Change location of browser on an URL.
|
Change location of browser on an URL.
|
||||||
|
|
@ -362,8 +362,3 @@ class BaseBrowser(mechanize.Browser):
|
||||||
self[field] = value
|
self[field] = value
|
||||||
except ClientForm.ControlNotFoundError:
|
except ClientForm.ControlNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
||||||
def post_request(self, url, data, headers):
|
|
||||||
headers['User-Agent'] = self.USER_AGENT
|
|
||||||
req = urllib2.Request(url, urllib.urlencode(data), headers)
|
|
||||||
return urllib2.urlopen(req)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue