def post_process(self, obj_id, items): for blitem in items: # print blitem typex = blitem['t'] if ControlType.is_url(typex): send_url(obj_id, blitem['v']) elif ControlType.is_twitter(typex): queue_twitter_resolution(obj_id, blitem['v'])
def do_post_process(item): # print 'signal:' + str(item) # current_app.logger.info(str(item)) object_id = str(item['_id']) items = item['i'] for element in items: typex = element['t'] if ControlType.is_url(typex): send_url(object_id, element['v']) elif ControlType.is_twitter(typex): queue_twitter_resolution(object_id, element['v'])
def has_post_process(item): elements = item.get('i', []) post_process = ControlType.get_post_process_controls() for elem in elements: if elem['t'] in post_process: return True return False
def get_blitem_item(self, key, value, labels): value = value.strip() slug = key[3:] typex = key[:2] blitem = {} blitem['t'] = typex blitem['s'] = slug blitem['v'] = ControlType.get_value(typex, value) blitem['l'] = labels.get(slug) return blitem
def get_blitem_from_request(self, key, value, control): value = value.strip() blitem = {} blitem['t'] = control['type'] blitem['s'] = control['slug'] value = ControlType.get_value(control['type'], value) blitem['v'] = value blitem['l'] = control['name'] return blitem
def updateTwitterItem(user_list, namesBag): for user in user_list: name = user.get('screen_name') u_id = getObjectId(name, namesBag) if u_id is not None: logger.debug('Update Item ' + str(u_id) + ' with ' + str(user)) blitem = Blitem.get({'_id': ObjectId(u_id)}) items = blitem['i'] for item in items: type = item['t'] if ControlType.is_twitter(type): item['cv'] = user logger.debug(str(blitem)) Blitem.save(blitem)
def test_getControls(self): twitter = 61 print ControlType.is_twitter(twitter) print ControlType.get_type(twitter)