comparison README.txt @ 30:a99009a7013c 0.3.1a

- Use generator with __getfile__ (uses much less memory) - Fixed security issue with __getfile__ - do not allow access to whole disk! - Handle exceptions in auth function - Fixed encrypting of no password - Changed README code examples
author Ben Croston <ben@croston.org>
date Thu, 05 Apr 2012 20:45:56 +0100
parents bea0c77734ca
children fdddfd434bbd
comparison
equal deleted inserted replaced
29:b631d13b252d 30:a99009a7013c
18 class api(object): 18 class api(object):
19 def do_something(self, myvar): 19 def do_something(self, myvar):
20 """Your code placed here""" 20 """Your code placed here"""
21 return 'Something', myvar 21 return 'Something', myvar
22 22
23 application = AuthRPCApp(api(), auth=myauth) 23 application = AuthRPCApp(api(), auth=myauth, filepath='/home/myapp/datadir')
24 simple_server.make_server('localhost', 1234, application) 24 server = simple_server.make_server('localhost', 1234, application)
25 server.serve_forever()
25 26
26 Example Usage (Client): 27 Example Usage (Client):
27 28
28 :: 29 ::
29 30
32 client = ServerProxy('http://localhost:1234/', 33 client = ServerProxy('http://localhost:1234/',
33 username='myuser', 34 username='myuser',
34 password='secret', 35 password='secret',
35 user_agent='myprogram') 36 user_agent='myprogram')
36 retval = client.do_something('test') 37 retval = client.do_something('test')
37 file_contents = client.__getfile__('myfile.pdf') 38
39 # get a file and save local copy
40 file_contents_generator = client.__getfile__('myfile.pdf')
41 with open('myfile_downloaded.pdf', 'wb') as f:
42 for data in file_contents_generator:
43 f.write(data)
44
38 batch = BatchCall(client) 45 batch = BatchCall(client)
39 batch.do_something('call 1') 46 batch.do_something('call 1')
40 batch.do_something('call 2') 47 batch.do_something('call 2')
41 batch() 48 batch()
42 49