View Single Post
blubbi's Avatar
Posts: 288 | Thanked: 113 times | Joined on Dec 2009 @ Germany
#34
Originally Posted by MaRRo81 View Post
I've just discovered an interesting thing: if you send an email to someone you don't have in your personal address book, the N900 standard email client will add the email address to the address book.: your address book will show something like xxx@yyy.com. If you open the contact you will see that only an email address is present (no name, surname or alias present)

If you try to create an email contact directly from your address book, it will ask you to put a name at least...this means is impossible to add only an email address...

Let's go back to our program: If the email address is present in my address book, the program doesn't work and it shows me this error:

Traceback (most recent call last):
File "/opt/www2sms/www2sms.py", line 451, in <module>
ui = MainWindow()
File "/opt/www2sms/www2sms.py", line 55, in __init__
self.my_phone_book = self.get_contacts()
File "/opt/www2sms/www2sms.py", line 200, in get_contacts
contact_and_numbers = [item.decode('utf-8')]
AttributeError: 'list' object has no attribute 'decode'

If I delete this email contact, the program works fine!

Just one thing: now the problem seems to appear only with the previous version (the one installed through the app. manager). The new one gave me this problem only once!
Aha, maybe you should file a Bug about this... Adding contacts without names automatically... but disallow the same if you add a contact manually.

Okay, the new one (v1.0.1) should no longer stumble upon this cause it was just a left over that I added "item" for this special case as a list instead of a string.

The part of the code where this happend:
v1.0.0
Code:
for econtact in contacts:
 contact = [econtact.get_property(name_attributes[2]), econtact.get_property(name_attributes[1]), econtact.get_property(name_attributes[3])]
 if contact[0] and contact[1]:
  item = "%s, %s" %(contact[0], contact[1])
 elif contact[0] and not contact[1]:
  item = "%s" %(contact[0])
 elif not contact[0] and contact[1]:
  item = "%s" %(contact[1])
 elif not contact[0] and not contact[1] and contact[2]:
  item = "%s" %(contact[2])
 else:
  item = ["No name available"]
# Everything is stored in UTF-8 so we decode it for the QT-GUI
contact_and_numbers = [item.decode('utf-8')]
So it was just to change from:
item = ["No name available"]
to
item = "No name available"

Thanks for the testing!