Package puremvc :: Package patterns :: Module mediator
[hide private]
[frames] | no frames]

Source Code for Module puremvc.patterns.mediator

  1  """ 
  2   PureMVC Python Port by Toby de Havilland <toby.de.havilland@puremvc.org> 
  3   PureMVC Python Port by Daniele Esposti <expo@expobrain.net> 
  4   PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 
  5   Your reuse is governed by the Creative Commons Attribution 3.0 License 
  6  """ 
  7   
  8  import puremvc.interfaces 
  9  import puremvc.patterns.observer 
 10   
11 -class Mediator(puremvc.patterns.observer.Notifier, puremvc.interfaces.IMediator):
12 """ 13 A base C{IMediator} implementation. 14 15 @see: L{View<puremvc.core.View>} 16 """ 17 18 """ 19 The name of the C{Mediator}. 20 """ 21 NAME = "Mediator" 22
23 - def __init__(self, mediatorName=None, viewComponent=None):
24 """ 25 Mediator Constructor 26 27 Typically, a C{Mediator} will be written to serve 28 one specific control or group controls and so, 29 will not have a need to be dynamically named. 30 """ 31 # Call superclass 32 super(Mediator, self).__init__() 33 34 # Initialize class 35 self.mediatorName = self.NAME if mediatorName is None else mediatorName 36 self.viewComponent = viewComponent
37
38 - def getMediatorName(self):
39 """ 40 Get the name of the C{Mediator}. 41 42 @return: the Mediator name 43 """ 44 return self.mediatorName
45
46 - def setViewComponent(self, viewComponent):
47 """ 48 Set the C{IMediator}'s view component. 49 50 @param viewComponent: the view component 51 """ 52 self.viewComponent = viewComponent
53
54 - def getViewComponent(self):
55 """ 56 Get the C{Mediator}'s view component. 57 58 Additionally, an implicit getter will usually be defined in the 59 subclass that casts the view object to a type, like this:: 60 61 private function get comboBox : mx.controls.ComboBox 62 { 63 return viewComponent as mx.controls.ComboBox; 64 } 65 66 @return: the view component 67 """ 68 return self.viewComponent
69
71 """ 72 List the C{INotification} names this 73 C{Mediator} is interested in being notified of. 74 75 @return: List the list of C{INotification} names 76 """ 77 return []
78
79 - def handleNotification(self, notification):
80 """ 81 Handle C{INotification}s. 82 83 Typically this will be handled in a if/else statement, 84 with one 'comparison' entry per C{INotification} 85 the C{Mediator} is interested in. 86 """ 87 pass
88
89 - def onRegister(self):
90 """ 91 Called by the View when the Mediator is registered 92 """ 93 pass
94
95 - def onRemove(self):
96 """ 97 Called by the View when the Mediator is removed 98 """ 99 pass
100