Package turbogears :: Package widgets :: Module rpc

Source Code for Module turbogears.widgets.rpc

 1  """TurboGears RPC base widget""" 
 2   
 3  __all__ = ['RPC'] 
 4   
 5  from turbogears.widgets.base import Widget, JSLink, static, mochikit 
 6  from turbojson import jsonify 
 7   
 8   
9 -class RPC(Widget):
10 """RPC base widget.""" 11 12 params = [ 13 'action', 'update', 'data', 14 'on_success', 'on_failure', 'on_complete', 15 'before', 'after', 'loading', 'loaded', 'confirm'] 16 17 javascript = [mochikit, JSLink(static,'ajax.js')] 18
19 - def update_params(self, d):
20 super(RPC, self).update_params(d) 21 22 d['js'] = "return ! remoteRequest(self, '%s', '%s', %s, %s)" % ( 23 d.get('action'), d.get('update'), 24 jsonify.encode(d.get('data')), 25 jsonify.encode(self.get_options(d)))
26
27 - def get_options(self, d):
28 return dict( 29 on_success=d.get('on_success'), 30 on_failure=d.get('on_failure'), 31 on_complete=d.get('on_complete'), 32 before=d.get('before'), 33 after=d.get('after'), 34 loading=d.get('loading'), 35 loaded=d.get('loaded'), 36 confirm=d.get('confirm'))
37