예제 #1
0
    def GET(self):
        user_data = web.input(q="", dn="")

        # dn parameter:
        if user_data["dn"] != "":
            data = urllib.quote(user_data["dn"])
            path = "/dn-search?dn=" + data
            target = urlparse(config.iPA4uri + path)
            response, content = h.request(target.geturl(), method, body, config.headers)
            json_content = json.loads(content)
            if response.status != 200:
                web.internalerror()
                web.header("Content-Type", "text/xml")
                return view.error(json_content, home=web.ctx.home + web.ctx.path)

            web.header("Content-Type", "text/xml")
            return view.entry(json_content, home=web.ctx.home + web.ctx.path)

            # q parameter:
        if user_data["q"] != "":
            data = urllib.quote(user_data["q"])
            path = (
                "/advanced-search?description="
                + data
                + "&nomeResp="
                + data
                + "&cognomeResp="
                + data
                + "&descrizioneS="
                + data
                + "&nomeS="
                + data
            )
            target = urlparse(config.iPA4uri + path)
            response, content = h.request(target.geturl(), method, body, config.headers)
            json_content = json.loads(content)
            if response.status != 200:
                web.internalerror()
                web.header("Content-Type", "text/xml")
                return view.error(json_content, home=web.ctx.home + web.ctx.path)

            web.header("Content-Type", "text/xml")
            return view.searchResult(json_content, home=web.ctx.home + web.ctx.path)

            # no q or dn parameter: render search form
        else:
            web.header("Content-Type", "text/xml")
            return view.searchForm(web.ctx.home + web.ctx.path)
예제 #2
0
def notfound():
    # return web.notfound("Sorry, the page you were looking for was not found.")
    # You can use template result like below, either is ok:
    return web.notfound(view.error())
예제 #3
0
def notfound():
    # return web.notfound("Sorry, the page you were looking for was not found.")
    # You can use template result like below, either is ok:
    return web.notfound(view.error())