1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 from flumotion.common import errors, log
23 from flumotion.twisted import flavors
24 from flumotion.twisted.compat import implements
25
26 -class BaseAdminText(log.Loggable):
27 """
28 I am a base class for all Text-based Admin views.
29 I am a view on one component's properties.
30 """
31
32 implements(flavors.IStateListener)
33
34 logCategory = "admintext"
35
36 state = admin = 'hello pychecker'
37
38 - def __init__(self, state, admin):
39 """
40 @param state: state of component this is a UI for
41 @type state: L{flumotion.common.planet.AdminComponentState}
42 @type admin: L{flumotion.admin.admin.AdminModel}
43 @param admin: the admin model that interfaces with the manager for us
44 """
45 self.state = state
46 self.name = state.get('name')
47 self.admin = admin
48 self.debug('creating admin text for state %r' % state)
49
50 - def propertyErrback(self, failure, window):
51 failure.trap(errors.PropertyError)
52 self.warning("%s." % failure.getErrorMessage())
53
54 return None
55
56 - def setElementProperty(self, elementName, propertyName, value):
57 """
58 Set the given property on the element with the given name.
59 """
60 d = self.admin.setProperty(self.state, elementName, propertyName, value)
61 d.addErrback(self.propertyErrback, self)
62 return d
63
64 - def getElementProperty(self, elementName, propertyName):
65 """
66 Get the value of the given property of the element with the given name.
67
68 Returns: L{twisted.internet.defer.Deferred} returning the value.
69 """
70 d = self.admin.getProperty(self.state, elementName, propertyName)
71 d.addErrback(self.propertyErrback, self)
72 return d
73
74 - def callRemote(self, methodName, *args, **kwargs):
75 return self.admin.componentCallRemote(self.state, methodName,
76 *args, **kwargs)
77
78
79
80 - def propertyChanged(self, name, value):
81 """
82 Override this method to be notified of component's properties that
83 have changed.
84
85 I am meant to be overridden.
86 """
87 self.debug("property %s changed to %r" % (name, value))
88
90 """
91 Set up the admin view so it can display nodes.
92 """
93 raise NotImplementedError("Child class needs to implement setup")
94
95 - def uiStateChanged(self, stateObject):
98
99 - def stateSet(self, object, key, value):
100 self.uiStateChanged(object)
101
102
103 - def stateAppend(self, object, key, value):
104 self.uiStateChanged(object)
105
106
107 - def stateRemove(self, object, key, value):
108 self.uiStateChanged(object)
109
110
111
112 - def getCompletions(self, input):
114
115
116 - def runCommand(self, command):
118