Package turbogears :: Package widgets :: Module rpc

Source Code for Module turbogears.widgets.rpc

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