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
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
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
37