1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Provides decorator classes & funcitons.
18 """
19
21 """
22 @cvar classes: A list of remoted classes.
23 @cvar methods: A list of remoted methods.
24 @cvar stubs: A dict of stubs.
25 """
26 classes = []
27 methods = []
28 stubs = {}
29
30
32 """
33 Decorator used to register remotable classes.
34 @param cls: A class to register.
35 @type cls: python class.
36 """
37 Remote.classes.append(cls)
38 return cls
39
41 """
42 @param fn: A function related to an instancemethod.
43 @type fn: function
44 Decorator used to register methods that may
45 be invoked remotely.
46 """
47 Remote.methods.append(fn)
48 return fn
49
51 """
52 Get whether the specified instance method (im)
53 may be invoked remotely.
54 @param im: An instance method.
55 @type im: instancemethod
56 @return: True if exposed via @remotemethod decorator.
57 @rtype: bool
58 """
59 return im.im_func in Remote.methods
60
62 """
63 Decorator used to register sub classes.
64 @param ns: The stub namespace.
65 @type ns: str.
66 """
67 def decorator(cls):
68 Remote.stubs[ns] = cls
69 return cls
70 return decorator
71