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 - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved.  
 4   Your reuse is governed by the Creative Commons Attribution 3.0 License  
 5  """ 
 6   
 7  import puremvc.interfaces 
 8  import puremvc.patterns.observer 
 9  import puremvc.patterns.facade 
10   
11 -class Mediator(puremvc.patterns.observer.Notifier, puremvc.interfaces.IMediator, puremvc.interfaces.INotifier):
12 """ 13 A base C{IMediator} implementation. 14 15 @see: L{View<org.puremvc.as3.core.view.View>} 16 """ 17 18 NAME = "Mediator" 19 facade = None 20 viewComponent = None 21 mediatorName = None 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 self.facade = puremvc.patterns.facade.Facade.getInstance() 32 if mediatorName: 33 self.mediatorName = mediatorName 34 else: 35 self.mediatorName = self.NAME 36 self.viewComponent = viewComponent
37
38 - def getMediatorName(self):
39 """ 40 Get the name of the C{Mediator}. 41 @return: the Mediator name 42 """ 43 return self.mediatorName
44
45 - def setViewComponent(self,viewComponent):
46 """ 47 Set the C{IMediator}'s view component. 48 49 @param viewComponent: the view component 50 """ 51 self.viewComponent = viewComponent
52
53 - def getViewComponent(self):
54 """ 55 Get the C{Mediator}'s view component. 56 57 @return: the view component 58 """ 59 return self.viewComponent
60
62 """ 63 List the C{INotification} names this 64 C{Mediator} is interested in being notified of. 65 66 @return: List the list of C{INotification} names 67 """ 68 return []
69
70 - def handleNotification(self,notification):
71 """ 72 Handle C{INotification}s. 73 74 Typically this will be handled in a if/else statement, 75 with one 'comparison' entry per C{INotification} 76 the C{Mediator} is interested in. 77 """ 78 pass
79
80 - def onRegister(self):
81 """ 82 Called by the View when the Mediator is registered 83 """ 84 pass
85
86 - def onRemove(self):
87 """ 88 Called by the View when the Mediator is removed 89 """ 90 pass
91