Line | |
---|
1 | """ |
---|
2 | Ported to Python 3. |
---|
3 | """ |
---|
4 | |
---|
5 | from foolscap.api import Violation, RemoteException |
---|
6 | |
---|
7 | |
---|
8 | def add_version_to_remote_reference(rref, default): |
---|
9 | """I try to add a .version attribute to the given RemoteReference. I call |
---|
10 | the remote get_version() method to learn its version. I'll add the |
---|
11 | default value if the remote side doesn't appear to have a get_version() |
---|
12 | method.""" |
---|
13 | d = rref.callRemote("get_version") |
---|
14 | def _got_version(version): |
---|
15 | rref.version = version |
---|
16 | return rref |
---|
17 | def _no_get_version(f): |
---|
18 | f.trap(Violation, RemoteException) |
---|
19 | rref.version = default |
---|
20 | return rref |
---|
21 | d.addCallbacks(_got_version, _no_get_version) |
---|
22 | return d |
---|
Note: See
TracBrowser
for help on using the repository browser.