Example #1
0
 def set_gid_shorten_urls(self, gid, shorten):
     if shorten:
         self.set_destination_param(gid, 'cache', '',
                                    S1.cache_shorten_urls(), shorten)
     else:
         self.del_destination_param(gid, 'cache', '',
                                    S1.cache_shorten_urls())
Example #2
0
    def forget_source(self, master_gid, gid):
        """
        Removes source gid, unlinks all bindings associated with the source
        @param master_gid: master gid
        @param gid: source gid
        @return:
        """
        self.logger.info('Removing source [{0}:{1}]...'.format(
            master_gid, gid))
        destinations = self.get_destinations(gid)
        for destination in destinations:
            users = self.get_destination_users(gid, destination)
            for user in users:
                # source gid can be bound to destination that does not belong to this master gid
                # forget_destination will only remove bindings that belong to this master gid
                DataApi.forget_destination(self, self.logger, gid, destination,
                                           user)

        # remove the gid from the list of child accounts
        self.remove_linked_account(master_gid, gid)

        # clear gid data if no destinations left
        destinations = self.get_destinations(gid)
        if not destinations:
            self.logger.info(
                'Source [{0}:{1}] is orphaned, cleaning...'.format(
                    master_gid, gid))
            # remove user keys
            self.rc.delete(S1.gid_key(gid))
            self.rc.delete(S1.gid_log_key(gid))
            self.rc.delete(S1.links_key(gid))
            self.rc.delete(S1.cache_key(gid))
            self.del_destination_param(gid, 'cache', '',
                                       S1.cache_shorten_urls())
            # clear chache and remove gid from poller list
            self.remove_from_poller(gid)
            # remove tnc
            self.rc.hdel(S1.TERMS_OK_KEY, gid)
Example #3
0
 def get_gid_shorten_urls(self, gid):
     return self.get_destination_param(gid, 'cache', '',
                                       S1.cache_shorten_urls())