File: client.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 (45 lines) | stat: -rw-r--r-- 1,009 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
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import sys, os
import Pyro.util

sys.path.insert(0,os.pardir)	# to find testclient.py

import testclient

# Get a proxy with attrs 
test = testclient.getproxy('attributes',True)

name = raw_input('Enter a name: ')

# new way of doing things:
# direct attribute access!

print 'current sum=',test.sum
print 'last changed by',test.changedby

test.sum = test.sum+1
test.changedby = name

print 'new sum=',test.sum

# creating some new attributes
test.newattr1 = 'new_one'
test.newattr2 = 'new_two'

print 'new attr 1=',test.newattr1
print 'new attr 2=',test.newattr2

print 'Getting nested attribute from person object'
print 'name=',test.person.name
print ' age=',test.person.age
print 'Getting nested attrs using methods from person object'
print 'name=',test.person.getName()
print ' age=',test.person.getAge()

print '(the next attribute access should raise an exception)'
try:
	print 'not existing=',test.notexisting
except Exception,x:
	print "".join(Pyro.util.getPyroTraceback(x))