Package flumotion :: Package component :: Package base :: Module admin_text
[hide private]

Source Code for Module flumotion.component.base.admin_text

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3  # 
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 
 6  # All rights reserved. 
 7   
 8  # This file may be distributed and/or modified under the terms of 
 9  # the GNU General Public License version 2 as published by 
10  # the Free Software Foundation. 
11  # This file is distributed without any warranty; without even the implied 
12  # warranty of merchantability or fitness for a particular purpose. 
13  # See "LICENSE.GPL" in the source distribution for more information. 
14   
15  # Licensees having purchased or holding a valid Flumotion Advanced 
16  # Streaming Server license may use this file in accordance with the 
17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
18  # See "LICENSE.Flumotion" in the source distribution for more information. 
19   
20  # Headers in this file shall remain intact. 
21   
22  from zope.interface import implements 
23   
24  from flumotion.common import errors, log 
25  from flumotion.twisted import flavors 
26   
27  __version__ = "$Rev: 6125 $" 
28   
29   
30 -class BaseAdminText(log.Loggable):
31 """ 32 I am a base class for all Text-based Admin views. 33 I am a view on one component's properties. 34 """ 35 36 implements(flavors.IStateListener) 37 38 logCategory = "admintext" 39 40 state = admin = 'hello pychecker' 41
42 - def __init__(self, state, admin):
43 """ 44 @param state: state of component this is a UI for 45 @type state: L{flumotion.common.planet.AdminComponentState} 46 @type admin: L{flumotion.admin.admin.AdminModel} 47 @param admin: the admin model that interfaces with the manager for us 48 """ 49 self.state = state 50 self.name = state.get('name') 51 self.admin = admin 52 self.debug('creating admin text for state %r' % state)
53
54 - def callRemote(self, methodName, *args, **kwargs):
55 return self.admin.componentCallRemote(self.state, methodName, 56 *args, **kwargs)
57 58 ### child class methods to be overridden 59
60 - def setup(self):
61 """ 62 Set up the admin view so it can display nodes. 63 """ 64 raise NotImplementedError("Child class needs to implement setup")
65
66 - def uiStateChanged(self, stateObject):
67 # default implementation 68 pass
69
70 - def stateSet(self, object, key, value):
71 self.uiStateChanged(object)
72 73
74 - def stateAppend(self, object, key, value):
75 self.uiStateChanged(object)
76 77
78 - def stateRemove(self, object, key, value):
79 self.uiStateChanged(object)
80 81 82 # given an input text return possible completions
83 - def getCompletions(self, input):
84 return []
85 86 # run command, return string with result
87 - def runCommand(self, command):
88 return ""
89