def update_bookmark(oid, bookmark): if oid and bookmark: blitem = Blitem.get({'_id': ObjectId(oid)}) print str(blitem) items = blitem['i'] for item in items: # type = item['t'] # if ControlType.is_bookmark(type): item['v'] = bookmark # logger.debug(str(blitem)) Blitem.save(blitem)
def test_updateItems(self): blitem = Blitem() blitem.load('4f99146f2ba78b09b4000001') blitem.populate() items = blitem.items d = dict() d['l'] = 'http://docs.python.org/library/urlparse.html' d['d'] = "docs.python.org" for item in items: if BControl.isURL(item['t']): item['v'] = d blitem.items = items blitem.save()
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)