backported some aum stuff
This commit is contained in:
parent
a4dd17631f
commit
bcd63ee3e7
2 changed files with 17 additions and 4 deletions
|
|
@ -65,6 +65,10 @@ class AdopteUnMec(Browser):
|
||||||
'http://www.adopteunmec.com/(\w+)': ProfilePage, # a custom profile url
|
'http://www.adopteunmec.com/(\w+)': ProfilePage, # a custom profile url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
Browser.__init__(self, *args, **kwargs)
|
||||||
|
self.my_id = 0
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
if not self.is_on_page(LoginPage):
|
if not self.is_on_page(LoginPage):
|
||||||
self.home()
|
self.home()
|
||||||
|
|
@ -132,9 +136,13 @@ class AdopteUnMec(Browser):
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def get_my_id(self):
|
def get_my_id(self):
|
||||||
|
if self.my_id:
|
||||||
|
return self.my_id
|
||||||
|
|
||||||
if not self.is_on_page(HomePage):
|
if not self.is_on_page(HomePage):
|
||||||
self.home()
|
self.home()
|
||||||
return self.page.get_my_id()
|
self.my_id = self.page.get_my_id()
|
||||||
|
return self.my_id
|
||||||
|
|
||||||
@pageaccess
|
@pageaccess
|
||||||
def nb_new_mails(self):
|
def nb_new_mails(self):
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,11 @@ class Browser(mechanize.Browser):
|
||||||
if self.__cookie:
|
if self.__cookie:
|
||||||
self.__cookie.save()
|
self.__cookie.save()
|
||||||
|
|
||||||
|
def str(self, s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
s = s.encode('iso-8859-15', 'replace')
|
||||||
|
return s
|
||||||
|
|
||||||
def set_field(self, args, label, field=None, value=None, is_list=False):
|
def set_field(self, args, label, field=None, value=None, is_list=False):
|
||||||
try:
|
try:
|
||||||
if not field:
|
if not field:
|
||||||
|
|
@ -228,15 +233,15 @@ class Browser(mechanize.Browser):
|
||||||
if is_list:
|
if is_list:
|
||||||
if isinstance(is_list, (list, tuple)):
|
if isinstance(is_list, (list, tuple)):
|
||||||
try:
|
try:
|
||||||
value = [str(is_list.index(args[label]))]
|
value = [self.str(is_list.index(args[label]))]
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
if args[label]:
|
if args[label]:
|
||||||
print '[%s] %s: %s' % (label, args[label], e)
|
print '[%s] %s: %s' % (label, args[label], e)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
value = [str(args[label])]
|
value = [self.str(args[label])]
|
||||||
else:
|
else:
|
||||||
value = str(args[label])
|
value = self.str(args[label])
|
||||||
self[field] = value
|
self[field] = value
|
||||||
except ClientForm.ControlNotFoundError:
|
except ClientForm.ControlNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue