예제 #1
0
    def handler(req):

        res = webob.Response()

        res.status = status

        res.text =  zpt.rendering('error', dict(request=req,
                                                title=status,
                                                message=message))

        res.headerlist = [('Content-Type', 'text/html; charset=UTF-8')]

        return res
예제 #2
0
def get(req):
    u'''
    メソッド探して返す
    '''

    fmt = req.GET.get('format')
    rtype = req.GET.get('return')
    args = req.GET.get('args')

    if is_empty(args):
        args = []
    else:
        args = args.strip()

        if not args:
            args = []
        else:
            args = [x.strip() for x in args.split(',')]

    if rtype is not None:
        rtype = rtype.strip()

    if is_empty(rtype) and not args:
        result = []
    else:
        with session.Session() as sess:
            result = functions.search_by_type(sess, rtype, args)

    if fmt == 'json':
        return utils.make_json_resp(result)

    return zpt.rendering(
        'search',
        dict(results=result,
             request=req,
             return_type=rtype,
             args=', '.join(args)))
예제 #3
0
파일: search.py 프로젝트: shomah4a/sakuya
def get(req):
    u'''
    メソッド探して返す
    '''

    fmt = req.GET.get('format')
    rtype = req.GET.get('return')
    args = req.GET.get('args')

    if is_empty(args):
        args = []
    else:
        args = args.strip()

        if not args:
            args = []
        else:
            args = [x.strip() for x in args.split(',')]


    if rtype is not None:
        rtype = rtype.strip()

    if is_empty(rtype) and not args:
        result = []
    else:
        with session.Session() as sess:
            result = functions.search_by_type(sess, rtype, args)

    if fmt == 'json':
        return utils.make_json_resp(result)

    return zpt.rendering('search', dict(results=result,
                                        request=req,
                                        return_type=rtype,
                                        args=', '.join(args)))