#!/usr/bin/env python
import CORBA
import PortableServer
import Types

orb = CORBA.ORB_init(("foo", "bar"), "orbit-local-orb")
poa = PortableServer.RootPOA(orb)
poa.the_POAManager.activate()

iorfile = open("/tmp/python-test.ior", "r")
ior = iorfile.read()
iorfile.close()

server = orb.string_to_object(ior)

print "server.test_boolean(1) =", server.test_boolean(1)
print "server.test_short(10000) =", server.test_short(10000)
print "server.test_long(10000000) =", server.test_long(10000000)
print "server.test_float(1.10000001) =", server.test_float(1.10000001)
print "server.test_double(1.10000001) =", server.test_double(1.10000001)
print 'server.test_string("thisisatest") =', server.test_string("thisisatest")

class callee:
	def test_string(self, arg): return arg * 2

callback = callee()
callback_servant = Types.POA_Tester(callback)
poa.activate_object_with_id("mycallback\0", callback_servant)
ref = poa.servant_to_reference(callback_servant)
print "server.test_callback(ref) =", server.test_callback(ref)

newserver = server.test_factory()
print 'server.test_factory().test_string("testfactory") =',
print newserver.test_string("testfactory")

