Exemple #1
0
    def batch_create (self, src_sl, src_dbid, items):
        """See the documentation in folder.Folder"""

        my_dbid = self.get_dbid()
        c       = self.get_config()
        src_sync_tag = c.make_sync_label(src_sl.get_pname(), src_dbid)
        dst_sync_tag = c.make_sync_label(src_sl.get_pname(), my_dbid)

        success = True
        for item in items:

            ## CardDAV does not support a multiput operation. So we will have
            ## to PUT the damn items one at a time. What kind of a standard is
            ## this, anyway?

            cd = CDContact(self, con=item)
            cd.update_sync_tags(src_sync_tag, item.get_itemid(), save=True)
            self.add_contact(cd)            

            item.update_sync_tags(dst_sync_tag, cd.get_itemid())

            logging.info('Successfully created CardDAV entry for %30s (%s)',
                         cd.get_disp_name(), cd.get_itemid())

        return True
Exemple #2
0
    def batch_create(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(src_sl.get_pname(), src_dbid)
        dst_sync_tag = c.make_sync_label(src_sl.get_pname(), my_dbid)

        success = True
        for item in items:

            ## CardDAV does not support a multiput operation. So we will have
            ## to PUT the damn items one at a time. What kind of a standard is
            ## this, anyway?

            con_itemid = item.get_itemid_from_synctags(pname, 'cd')
            cd = CDContact(self, con=item, con_itemid=con_itemid)
            cd.update_sync_tags(src_sync_tag, item.get_itemid(), save=True)
            self.add_contact(cd)

            item.update_sync_tags(dst_sync_tag, cd.get_itemid())

            logging.info('Successfully created CardDAV entry for %30s (%s)',
                         cd.get_disp_name(), cd.get_itemid())

        return True
Exemple #3
0
    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
Exemple #4
0
    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