Пример #1
0
def main(args):
    parser = setup_options()
    (options, args) = parser.parse_args(args)
    if len(args) not in (2, 3):
        usage()

    url = args[1]
    rend = None
    if len(args) == 3:
        try:
            rend = htmlrends.get_renderer(args[2])
        except derrors.RendErr as e:
            die(str(e))

    try:
        app, r = dwconfig.materialize(args[0], options)
        # We're one of the people who actually needs this.
        cfg, ms, webserv, staticstore, cachestore = r
    except derrors.WikiErr as e:
        die("dwiki error: " + str(e))

    env = setup_env(url)
    if rend:
        httpcore.environSetup(env, cfg, ms, webserv, staticstore, cachestore)
        env['dwiki.logger'] = None
        rdata = httpcore.gather_reqdata(env)
        if 'query' not in rdata:
            die("URL %s is not accepted by the core" % url)
        ctx = context.HTMLContext(cfg, ms, webserv, rdata)
        if cachestore:
            ctx.setvar(':_cachestore', cachestore)
        runrend(rend, ctx)
    else:
        runwsgi(env, app)
Пример #2
0
def main(args):
	parser = setup_options()
	(options, args) = parser.parse_args(args)
	if len(args) not in (2, 3):
		usage()

	url = args[1]
	rend = None
	if len(args) == 3:
		try:
			rend = htmlrends.get_renderer(args[2])
		except derrors.RendErr as e:
			die(str(e))

	try:
		app, r = dwconfig.materialize(args[0], options)
		# We're one of the people who actually needs this.
		cfg, ms, webserv, staticstore, cachestore = r
	except derrors.WikiErr as e:
		die("dwiki error: "+str(e))

	env = setup_env(url)
	if rend:
		httpcore.environSetup(env, cfg, ms, webserv, staticstore,
				      cachestore)
		env['dwiki.logger'] = None
		rdata = httpcore.gather_reqdata(env)
		if 'query' not in rdata:
			die("URL %s is not accepted by the core" % url)
		ctx = context.HTMLContext(cfg, ms, webserv, rdata)
		if cachestore:
			ctx.setvar(':_cachestore', cachestore)
		runrend(rend, ctx)
	else:
		runwsgi(env, app)
Пример #3
0
def main(args):
	parser = setup_options()
	(options, args) = parser.parse_args(args)
	op = options.operation
	if len(args) not in (3, 4):
		usage()

	cnt = int(args[2])
	url = args[1]
	rend = None
	if len(args) == 4:
		try:
			rend = htmlrends.get_renderer(args[3])
		except derrors.RendErr as e:
			die(str(e))

	try:
		app, r = dwconfig.materialize(args[0], options)
		# We're one of the people who actually needs this.
		cfg, ms, webserv, staticstore, cachestore = r

	except derrors.WikiErr as e:
		die("dwiki error: "+str(e))

	env = setup_env(url)
	if options.ip6origin:
		# This format matches what the Fedora 17 lighttpd
		# puts into $REMOTE_ADDR. Your mileage may vary for
		# other web servers, although it's probably right
		# for Apache too.
		env['REMOTE_ADDR'] = "::1"
		
	if rend:
		httpcore.environSetup(env, cfg, ms, webserv, staticstore,
				      cachestore)
		env['dwiki.logger'] = None
		rdata = httpcore.gather_reqdata(env)
		if 'query' not in rdata:
			die("URL %s is not accepted by the core" % url)
		ctx = context.HTMLContext(cfg, ms, webserv, rdata)
		if cachestore:
			ctx.setvar(':_cachestore', cachestore)
		if options.prerun:
			runLimited(*(options.prerun, runrend, rend, ctx))
		op(cnt, runrend, rend, ctx)
	else:
		if options.prerun:
			runLimited(*(options.prerun, runwsgi, env, app))
		op(cnt, runwsgi, env, app)
Пример #4
0
def main(args):
    parser = setup_options()
    (options, args) = parser.parse_args(args)
    op = options.operation
    if len(args) not in (3, 4):
        usage()

    cnt = int(args[2])
    url = args[1]
    rend = None
    if len(args) == 4:
        try:
            rend = htmlrends.get_renderer(args[3])
        except derrors.RendErr as e:
            die(str(e))

    try:
        app, r = dwconfig.materialize(args[0], options)
        # We're one of the people who actually needs this.
        cfg, ms, webserv, staticstore, cachestore = r

    except derrors.WikiErr as e:
        die("dwiki error: " + str(e))

    env = setup_env(url)
    if options.ip6origin:
        # This format matches what the Fedora 17 lighttpd
        # puts into $REMOTE_ADDR. Your mileage may vary for
        # other web servers, although it's probably right
        # for Apache too.
        env["REMOTE_ADDR"] = "::1"

    if rend:
        httpcore.environSetup(env, cfg, ms, webserv, staticstore, cachestore)
        env["dwiki.logger"] = None
        rdata = httpcore.gather_reqdata(env)
        if "query" not in rdata:
            die("URL %s is not accepted by the core" % url)
        ctx = context.HTMLContext(cfg, ms, webserv, rdata)
        if cachestore:
            ctx.setvar(":_cachestore", cachestore)
        if options.prerun:
            runLimited(*(options.prerun, runrend, rend, ctx))
        op(cnt, runrend, rend, ctx)
    else:
        if options.prerun:
            runLimited(*(options.prerun, runwsgi, env, app))
        op(cnt, runwsgi, env, app)