def get_auth_bydetail(source_id, source_entity, grant_id, grant_entity): context = DBContext() return context.create_query( "um_auth", "sourceid=:sourceid and sourceentity=:sourceentity " "and grantid=:grantid and grantentity=:grantentity", sourceid=source_id, sourceentity=source_entity, grantid=grant_id, grantentity=grant_entity).first()
def find_schedule_logs(**params): sql = ['1=1'] cond = {} ctx = DBContext() if 'scheduleid' in params: sql.append('and scheduleid = :scheduleid') cond['scheduleid'] = params['scheduleid'] if 'status' in params: sql.append('and status = :status') cond['status'] = num.safe_int(params['status']) return ctx.create_query('cm_schedule_log', ' '.join(sql), **cond)
def find_schedules(**params): ctx = DBContext() sql = ['1=1'] cond = {} if 'enabled' in params: sql.append('and enabled = :enabled') cond['enabled'] = params['enabled'] if 'type' in params: sql.append('and type = :type') cond['type'] = params['type'] if 'module' in params: sql.append('and module = :module') cond['module'] = params['module'] if 'modulelike' in params: sql.append('and module like :modulelike') cond['modulelike'] = '%' + params['modulelike'] + '%' if 'sourceid' in params: sql.append('and sourceid = :sourceid') cond['sourceid'] = params['sourceid'] return ctx.create_query('cm_schedule', ' '.join(sql), **cond)
def find_auth(**params): context = DBContext() where = ['1=1'] argdict = {} for attribute in 'sourceentity', 'sourceid', 'grantentity', 'grantid': try: value = params[attribute] where.append('%s=:%s' % (attribute, attribute)) argdict[attribute] = value except KeyError: pass for a in 'sourceentityin', 'sourceidin', 'grantentityin', 'grantidin': try: attribute = a[:-2] values = params[a] if not isinstance(values, collections.Iterable): raise Exception('%s should be iterable', a) where.append('%s in %s' % (attribute, query.escape_sequence(values))) except KeyError: pass return context.create_query('um_auth', ' and '.join(where), **argdict)