File: server.py

package info (click to toggle)
pyro 1%3A3.14-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,048 kB
  • ctags: 1,988
  • sloc: python: 11,194; xml: 128; sh: 52; makefile: 28
file content (37 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import sys
import Pyro.naming
import Pyro.core
from Pyro.errors import PyroError,NamingError

class testobject(Pyro.core.ObjBase):
	def __init__(self):
		Pyro.core.ObjBase.__init__(self)
	def method(self,arg):
		print 'Method called with',arg
		return 'An interesting result'


# initialize the server
Pyro.core.initServer()

# locate the NS
print 'Searching Naming Service...'
locator = Pyro.naming.NameServerLocator(identification='s3cr3t') # note the ident string
ns = locator.getNS()

try:
    ns.createGroup(":test")
except NamingError:
    pass

daemon = Pyro.core.Daemon()
daemon.useNameServer(ns)
daemon.setAllowedIdentifications(['s3cr3t'])

# connect new instance, but using persistent mode
daemon.connectPersistent(testobject(),':test.authentication')

# enter the service loop.
print 'Server started.'
daemon.requestLoop()