comparison libervia.tac @ 1:0a7c685faa53

ContactPanel: first draft
author Goffi <goffi@goffi.org>
date Mon, 31 Jan 2011 20:31:25 +0100
parents 140cec48224a
children 669c531a857e
comparison
equal deleted inserted replaced
0:140cec48224a 1:0a7c685faa53
40 def __init__(self, sat_host): 40 def __init__(self, sat_host):
41 jsonrpc.JSONRPC.__init__(self) 41 jsonrpc.JSONRPC.__init__(self)
42 self.sat_host=sat_host 42 self.sat_host=sat_host
43 43
44 def render(self, request): 44 def render(self, request):
45 _session = request.getSession() 45 self.session = request.getSession()
46 try: 46 try:
47 profile = _session.sat_profile 47 profile = self.session.sat_profile
48 except AttributeError: 48 except AttributeError:
49 #user is not identified, we return a jsonrpc fault 49 #user is not identified, we return a jsonrpc fault
50 parsed = jsonrpclib.loads(request.content.read()) 50 parsed = jsonrpclib.loads(request.content.read())
51 fault = jsonrpclib.Fault(0, "Not allowed") #FIXME: define some standard error codes for libervia 51 fault = jsonrpclib.Fault(0, "Not allowed") #FIXME: define some standard error codes for libervia
52 return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc')) 52 return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc'))
53 return jsonrpc.JSONRPC.render(self, request) 53 return jsonrpc.JSONRPC.render(self, request)
54 54
55 55
56 def jsonrpc_getContacts(self): 56 def jsonrpc_getContacts(self):
57 """Return all passed args.""" 57 """Return all passed args."""
58 d = defer.Deferred() 58 profile = self.session.sat_profile
59 reactor.callLater(10, d.callback, [unicode(contact[0]) for contact in self.sat_host.bridge.getContacts()]) 59 return self.sat_host.bridge.getContacts(profile)
60 return d
61 60
62 class Register(jsonrpc.JSONRPC): 61 class Register(jsonrpc.JSONRPC):
63 """This class manage the registration procedure with SàT 62 """This class manage the registration procedure with SàT
64 It provide an api for the browser, check password and setup the web server""" 63 It provide an api for the browser, check password and setup the web server"""
65 64
230 self.bridge.register("connected", self.signal_handler.connected) 229 self.bridge.register("connected", self.signal_handler.connected)
231 self.bridge.register("connectionError", self.signal_handler.connectionError) 230 self.bridge.register("connectionError", self.signal_handler.connectionError)
232 231
233 def startService(self): 232 def startService(self):
234 reactor.listenTCP(8080, self.site) 233 reactor.listenTCP(8080, self.site)
235 234
236 def run(self): 235 def run(self):
237 debug(_("running app"))
238 reactor.run() 236 reactor.run()
239 237
240 def stop(self): 238 def stop(self):
241 debug(_("stopping app"))
242 reactor.stop() 239 reactor.stop()
243 240
244 241
245 242
246 application = service.Application('Libervia') 243 application = service.Application('Libervia')