7 _moduleLogger = logging.getLogger("gvoice.addressbook")
10 class Addressbook(object):
12 def __init__(self, backend):
13 self._backend = backend
16 def clear_cache(self):
17 self._contacts.clear()
19 def get_contacts(self):
20 self._populate_contacts()
21 return self._contacts.iterkeys()
23 def get_contact_details(self, contactId):
24 self._populate_contacts()
25 self._populate_contact_details(contactId)
26 return self._contacts[contactId]
28 def _populate_contacts(self):
31 contacts = self._backend.get_contacts()
32 for contactId, contactName in contacts:
33 self._contacts[contactId] = None
35 def _populate_contact_details(self, contactId):
36 if self._contacts[contactId] is not None:
38 self._contacts[contactId] = self._backend.get_contact_details(contactId)