def zfwbimg_delete_uid(uid, session=None): if not session: session = get_session() zfwbimgs = zfwbimg_get_by_uid(uid) for zfwbimg in zfwbimgs: zfwbimg.delete()
def zfwbtext_delete_mid(mid, session=None): if not session: session = get_session() zfwbtext = zfwbtext_get_by_mid(mid) if zfwbtext: zfwbtext.delete(session)
def zfwbtext_delete_uid(uid, session=None): if not session: session = get_session() zfwbtexts = zfwbtext_get_by_uid(uid) for zfwbtext in zfwbtexts: zfwbtext.delete(session)
def zfwbtext_delete(id, session=None): if not session: session = get_session() zfwbtexts = zfwbtext_get_by_id(id) for zfwbtext in zfwbtexts: zfwbtext.delete(session)
def zfwbimg_delete(id, session=None): if not session: session = get_session() zfwbimg = zfwbimg_get_by_id(id) if zfwbimg: zfwbimg.delete()
def wbimg_delete_uid(uid, session=None): if not session: session = get_session() wbimgs = wbimg_get_by_uid(uid) if wbimg in wbimgs: wbimg.delete()
def weibo_delete_mid(mid, session=None): if not session: session = get_session() weibo = weibo_get_by_mid(mid) if weibo: weibo.delete()
def model_query(model, *args, **kwargs): """Query helper that accounts for context's `read_deleted` field. :param session: if present, the session to use :param read_deleted: if present, overrides context's read_deleted field. :param project_only: if present and context is user-type, then restrict query to match the context's project_id. If set to 'allow_none', restriction includes project_id = None. """ read_deleted = kwargs.get('read_deleted', 'no') session = kwargs.get('session') or get_session() query = session.query(model, *args) if read_deleted == 'no': query = query.filter_by(deleted=False) elif read_deleted == 'yes': pass # omit the filter to include deleted and active elif read_deleted == 'only': query = query.filter_by(deleted=True) else: raise Exception( _("Unrecognized read_deleted value '%s'") % read_deleted) return query
def wbtext_delete_uid(uid, session=None): if not session: session = get_session() wbtexts = wbtext_get_by_uid(uid) if wbtext in wbtexts: wbtext.delete()
def wbimg_delete_mid(mid, session=None): if not session: session = get_session() wbimg = wbimg_get_by_mid(mid) if wbimg: wbimg.delete()
def wbtext_delete_mid(mid, session=None): if not session: session = get_session() wbtext = wbtext_get_by_mid(mid) if wbtext: wbtext.delete()
def weibo_delete_uid(uid, session=None): if not session: session = get_session() weibos = weibo_get_by_uid(uid) if weibo in weibos: weibo.delete()
def wbimg_delete_uid(uid, session=None): if not session: session = get_session() wbimgs = wbimg_get_by_uid(uid) for wbimg in wbimgs: wbimg.delete()
def zfwbtext_delete_uid(uid, session=None): if not session: session = get_session() zfwbtexts = zfwbtext_get_by_uid(uid) if zfwbtext in zfwbtexts: zfwbtext.delete()
def zfwbtext_delete(id, session=None): if not session: session = get_session() zfwtext = zfwbtext_get_by_id(id) if zfwbtext: zfwbtext.delete()
def weibo_delete_uid(uid, session=None): if not session: session = get_session() weibos = weibo_get_by_uid(uid) for weibo in weibos: weibo.delete()
def zfwbtext_delete_mid(mid, session=None): if not session: session = get_session() zfwbtext = zfwbtext_get_by_mid(mid) if zfwbtext: zfwbtext.delete()
def wbtext_delete_uid(uid, session=None): if not session: session = get_session() wbtexts = wbtext_get_by_uid(uid) for wbtext in wbtexts: wbtext.delete()
def zfwbimg_delete_uid(uid, session=None): if not session: session = get_session() zfwbimgs = zfwbimg_get_by_uid(uid) if zfwbimg in zfwbimgs: zfwbimg.delete()
def zfwbimg_delete_mid(mid, session=None): if not session: session = get_session() zfwbimgs = zfwbimg_get_by_mid(mid) for zfwbimg in zfwbimgs: zfwbimg.delete()
def weibo_update(values, session=None): if not session: session = get_session() mid = values.pop('mid') with session.begin(): weibo = weibo_get_by_mid(mid, session=session) weibo.update(values) weibo.save(session=session) return weibo_get_by_mid(mid)
def zfwbtext_update(values, session=None): if not session: session = get_session() mid = values.pop('mid') with session.begin(): zfwbtext = zfwbtext_get_by_mid(mid, session=session) zfwbtext.update(values) zfwbtext.save(session=session) return zfwbtext_get_by_mid(mid)
def zfwbimg_update(values, session=None): if not session: session = get_session() url = values.get('url') with session.begin(): zfwbimg = zfwbimg_get_by_url(url, session=session) zfwbimg.update(values) zfwbimg.save(session=session) return zfwbimg_get_by_url(url)
def userdata_update(values, session=None): if not session: session = get_session() uid = values.pop('uid') with session.begin(): userdata = userdata_get_by_uid(uid, session=session) userdata.update(values) userdata.save(session=session) return userdata_get_by_uid(uid)
def service_update(service_id, values): session = get_session() with session.begin(): service_ref = _service_get(service_id, session=session) # Only servicegroup.drivers.db.DbDriver._report_state() updates # 'report_count', so if that value changes then store the timestamp # as the last time we got a state report. if 'report_count' in values: if values['report_count'] > service_ref.report_count: service_ref.last_seen_up = timeutils.utcnow() service_ref.update(values) return service_ref
def userdata_create(values): session = get_session() userdata = _get_query(models.Userdata, models.Userdata.uid, values['uid'], session=session, read_deleted='no').first() if not userdata: userdata = models.Userdata() userdata.update(values) userdata.save(session=session) else: raise exception.UserdataNameExists(userdata_name=values['name']) return userdata_get_by_uid(userdata.uid)
def zfwbtext_create(values, session=None): if not session: session = get_session() zfwbtext = _get_query(models.Zfwbtext, models.Zfwbtext.mid, values['mid'], session=session, read_deleted='no').first() if not zfwbtext: zfwbtext = models.Zfwbtext() zfwbtext.update(values) zfwbtext.save(session=session) else: raise exception.ZfwbtextMidExists(mid=mid) return zfwbtext_get_by_mid(zfwbtext.mid)
def weibo_create(values, session=None): if not session: session = get_session() weibo = _get_query(models.Weibo, models.Weibo.mid, values['mid'], session=session, read_deleted='no').first() if not weibo: weibo = models.Weibo() weibo.update(values) weibo.save(session=session) else: raise exception.WeiboMidExists(mid=mid) return weibo_get_by_mid(weibo.mid)
def weibo_create(values, session=None): if not session: session = get_session() weibo = _get_query(models.Weibo, models.Weibo.mid, values['mid'], session=session, read_deleted='no').first() if not weibo: weibo = models.Weibo() weibo.update(values) weibo.save(session=session) else: raise exception.WeiboMidExists(mid=values['mid']) return weibo_get_by_mid(weibo.mid)
def zfwbtext_create(values, session=None): if not session: session = get_session() zfwbtext = _get_query(models.Zfwbtext, models.Zfwbtext.mid, values['mid'], session=session, read_deleted='no').first() if not zfwbtext: zfwbtext = models.Zfwbtext() zfwbtext.update(values) zfwbtext.save(session=session) else: raise exception.ZfwbtextMidExists(mid=values['mid']) return zfwbtext_get_by_mid(zfwbtext.mid)
def zfwbimg_create(values, session=None): if not session: session = get_session() url = values['url'] zfwbimg = _get_query(models.Zfwbimg, models.Zfwbimg.url, url, session=session, read_deleted='no').first() if not zfwbimg: zfwbimg = models.Zfwbimg() zfwbimg.update(values) zfwbimg.save(session=session) else: raise exception.ZfwbimgUrlExists(url=url) return zfwbimg_get_by_url(zfwbimg.url)
def userdata_delete_uid(uid): session = get_session() userdata = userdata_get_by_uid(uid) if userdata: userdata.delete()
def userdata_get_all(session=None): if not session: session = get_session() result = model_query(models.Userdata, session=session) return result.all()
def userdata_delete(id): session = get_session() userdata = userdata_get_by_id(id, session) if userdata: userdata.delete(session)
def userdata_delete_name(name): session = get_session() userdata = userdata_get_by_name(name, session) if userdata: userdata.delete(session)
def userdata_delete_name(name): session = get_session() userdata = userdata_get_by_name(name) if userdata: userdata.delete()