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,2008,2009 Fluendo, S.L. 
 6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
 7  # All rights reserved. 
 8  # 
 9  # This file may be distributed and/or modified under the terms of 
10  # the GNU Lesser General Public License version 2.1 as published by 
11  # the Free Software Foundation. 
12  # This file is distributed without any warranty; without even the implied 
13  # warranty of merchantability or fitness for a particular purpose. 
14  # See "LICENSE.LGPL" in the source distribution for more information. 
15  # 
16  # Headers in this file shall remain intact. 
17   
18  from zope.interface import implements 
19   
20  from flumotion.common import log 
21  from flumotion.twisted import flavors 
22   
23  __version__ = "$Rev$" 
24   
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 callRemote(self, methodName, *args, **kwargs):
51 return self.admin.componentCallRemote(self.state, methodName, 52 *args, **kwargs)
53 54 ### child class methods to be overridden 55
56 - def setup(self):
57 """ 58 Set up the admin view so it can display nodes. 59 """ 60 raise NotImplementedError("Child class needs to implement setup")
61
62 - def uiStateChanged(self, stateObject):
63 # default implementation 64 pass
65
66 - def stateSet(self, object, key, value):
67 self.uiStateChanged(object)
68
69 - def stateAppend(self, object, key, value):
70 self.uiStateChanged(object)
71
72 - def stateRemove(self, object, key, value):
73 self.uiStateChanged(object)
74 75 # given an input text return possible completions 76
77 - def getCompletions(self, input):
78 return []
79 80 # run command, return string with result 81
82 - def runCommand(self, command):
83 return ""
84