Пример #1
0
def test(request):
    return {'dicttest': "This is a test",
            'requestTest': request.getConfiguration()['blog_title'],
            'list test': [1, 2, 3, 'Go!'],
            'complex list/dict': ['hi', {'test': 'A test',
            'list':['list']}]}

def sureFireFault(request):
    raise IOError, 'This is why you should give up programming'

def cb_xmlrpc_register(args):
    args["methods"].update(
           {'math.add': add,
            'math.sub': sub,
            'system.test': test,
            'system.fault': sureFireFault})

    return args

if __name__ == '__main__':
    from Pyblosxom.Request import Request
    from pprint import pprint
    request = Request()
    request.addConfiguration({'blog_title': 'RoughingIT'})

    pprint(test(request))
    pprint(add(request, 1, 2))
    pprint(sub(request, 1, 2))
    pprint(sureFireFault(request))
Пример #2
0
if __name__ == '__main__':
    redir = os.environ.get('REDIRECT_URI', '')
    if redir == '':
        redir = os.environ.get('REDIRECT_URL', '')
    pathInfo = re.sub(archiveRoot, '', redir)
    if redir.startswith(archiveRoot):
        stdout = sys.stdout
        sys.stdout = StringIO()
        os.environ['PATH_INFO'] = pathInfo
        os.environ['SCRIPT_NAME'] = pyblosxomScriptPath
        os.environ['HTTP_HOST'] = hostName
        from Pyblosxom.pyblosxom import PyBlosxom
        from Pyblosxom.Request import Request
        import os, cgi

        req = Request()
        req.addConfiguration(config.py)

        d = {}
        for mem in ["PATH_INFO", "SCRIPT_NAME", "REQUEST_METHOD", "HTTP_HOST", "QUERY_STRING", "REQUEST_URI", "HTTP_USER_AGENT", "REMOTE_ADDR"]:
            d[mem] = os.environ.get(mem, "")
        req.addHttp(d)

        req.addHttp({"form": cgi.FieldStorage()})

        p = PyBlosxom(req)
        p.startup()
        p.run()
        data = sys.stdout.getvalue()
        sys.stdout = stdout
        saveData(docRoot + pathInfo, data)
Пример #3
0
if __name__ == '__main__':
    redir = os.environ.get('REDIRECT_URI', '')
    if redir == '':
        redir = os.environ.get('REDIRECT_URL', '')
    pathInfo = re.sub(archiveRoot, '', redir)
    if redir.startswith(archiveRoot):
        stdout = sys.stdout
        sys.stdout = StringIO()
        os.environ['PATH_INFO'] = pathInfo
        os.environ['SCRIPT_NAME'] = pyblosxomScriptPath
        os.environ['HTTP_HOST'] = hostName
        from Pyblosxom.pyblosxom import PyBlosxom
        from Pyblosxom.Request import Request
        import os, cgi

        req = Request()
        req.addConfiguration(config.py)

        d = {}
        for mem in ["PATH_INFO", "SCRIPT_NAME", "REQUEST_METHOD", "HTTP_HOST", "QUERY_STRING", "REQUEST_URI", "HTTP_USER_AGENT", "REMOTE_ADDR"]:
            d[mem] = os.environ.get(mem, "")
        req.addHttp(d)

        req.addHttp({"form": cgi.FieldStorage()})

        p = PyBlosxom(req)
        p.startup()
        p.run()
        data = sys.stdout.getvalue()
        sys.stdout = stdout
        saveData(docRoot + pathInfo, data)