#!/usr/bin/env python3 import json result = [] try: async with get_sor_context(request._run_ns, 'uapi') as sor: user_orgid = await get_userorgid() apps = await sor.sqlExe( "select id, name from upapp where ownerid = ${ownerid}$ or ownerid is null order by name", {'ownerid': user_orgid} ) result = [{'value': r['id'], 'text': r['name']} for r in (apps or [])] except Exception as e: pass return json.dumps(result, ensure_ascii=False, default=str)