--- /dev/null
+package = "pagos"
+version = "alpha0.0.1"
+source = {
+ url = "*** please add URL for source tarball, zip or repository here ***"
+}
+description = {
+ summary = "",
+ detailed = "",
+ homepage = "*** please enter a project homepage ***",
+ license = "GPLv2"
+}
+build = {
+ type = "builtin",
+ modules = {},
+ copy_directories = {
+ "docs"
+ }
+}
--- /dev/null
+package.path = "../lua_modules/share/lua/5.1/?.lua;../lua_modules/share/lua/5.1/?/init.lua;" .. package.path
+package.cpath = "../lua_modules/lib/lua/5.1/?.so;" .. package.cpath
+
+require "xmlrpc.http"
+
+function XMLRPCWrapper(host)
+ local o = { }
+ setmetatable(o, {
+ __index = function(t, func_name)
+ return function(...)
+ local ok, res = xmlrpc.http.call(host, func_name, ...)
+ assert(ok, "RPC failed on " .. func_name)
+ return res
+ end
+ end;
+ })
+
+ return o
+end
+
+local app = XMLRPCWrapper("http://localhost:8000/RPC2")
+
+print("Result: " .. app.add(2, 3))
+print("Something: " .. app.add_and_get())
+
+print("Sum: " .. app.sum({ 1, 2, 3, 4, 5 }))
+
+local primes = app.get_some_primes()
+for key, prime in ipairs(primes) do
+ print(prime[1], prime[2])
+end
def add(x, y):
return x + y
+ @server.register_function()
+ def sum(numbers):
+ from functools import reduce
+
+ value = reduce(lambda a, b: a + b, numbers.values())
+ return value
+
+ @server.register_function()
+ def get_some_primes():
+ return [ (1, 2), (2, 3), (3, 5), (4, 7), (5, 11), (6, 13) , (7, 17) ]
+
server.register_instance(SomeState())
server.serve_forever()