# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import Pyro4

class Data(object):
  def __init__(self, _iv = 0, _sv = ''):
    self.iv = _iv
    self.sv = _sv
    
@Pyro4.expose
class Test(object):
    def __init__(self):
        self.counter = 0
    def add(self,a,b):
        return a + b
    def dup(self,s):
        return s + s
    def process(self,d):
        return Data(d.iv + 1, d.sv + 'X')
    def getCounter(self):
        self.counter = self.counter + 1
        return self.counter
    def noop(self):
        return

Pyro4.config.SERIALIZER = 'dill'

srv = Pyro4.Daemon()
uri = srv.register(Test)
ns = Pyro4.locateNS('localhost', 9090)
ns.register('Test', uri)

srv.requestLoop()
