def batch_update(self, src_sl, src_dbid, items): """See the documentation in folder.Folder""" my_dbid = self.get_dbid() c = self.get_config() pname = src_sl.get_pname() src_sync_tag = c.make_sync_label(pname, src_dbid) dst_sync_tag = c.make_sync_label(pname, my_dbid) cons = self.get_contacts() ## FIXME: We will try to overwrite using the etags we had fetched just ## a fe moments back. It could still fail; and the error handling ## needs to be robust ... but it is not success = True for item in items: tag, href = item.get_sync_tags(dst_sync_tag)[0] ## FIXME: Some times we might find it expedient to force a ## "update" without the contact being present int he remote. If ## that happens the next line will throw an KeyError. You are ## warned. con_old = cons[href] con_itemid = item.get_itemid_from_synctags(pname, 'cd') con_new = CDContact(self, con=item, con_itemid=con_itemid) con_new.set_uid(con_old.get_uid()) con_new.update_sync_tags(src_sync_tag, item.get_itemid()) try: con_new.save(etag=con_old.get_etag()) logging.info( 'Successfully updated CardDAV entry for %30s (%s)', con_new.get_disp_name(), con_new.get_itemid()) except HTTPError, e: logging.error('Error (%s). Could not update CardDAV entry %s', e, con_new.get_disp_name()) success = False
def batch_update (self, src_sl, src_dbid, items): """See the documentation in folder.Folder""" my_dbid = self.get_dbid() c = self.get_config() pname = src_sl.get_pname() src_sync_tag = c.make_sync_label(pname, src_dbid) dst_sync_tag = c.make_sync_label(pname, my_dbid) cons = self.get_contacts() ## FIXME: We will try to overwrite using the etags we had fetched just ## a fe moments back. It could still fail; and the error handling ## needs to be robust ... but it is not success = True for item in items: tag, href = item.get_sync_tags(dst_sync_tag)[0] ## FIXME: Some times we might find it expedient to force a ## "update" without the contact being present int he remote. If ## that happens the next line will throw an KeyError. You are ## warned. con_old = cons[href] con_itemid = item.get_itemid_from_synctags(pname, 'cd') con_new = CDContact(self, con=item, con_itemid=con_itemid) con_new.set_uid(con_old.get_uid()) con_new.update_sync_tags(src_sync_tag, item.get_itemid()) try: con_new.save(etag=con_old.get_etag()) logging.info('Successfully updated CardDAV entry for %30s (%s)', con_new.get_disp_name(), con_new.get_itemid()) except HTTPError, e: logging.error('Error (%s). Could not update CardDAV entry %s', e, con_new.get_disp_name()) success = False