puremvc :: patterns :: facade :: Facade :: Class Facade
[hide private]
[frames] | no frames]

Class Facade

source code

          object --+        
                   |        
interfaces.INotifier --+    
                       |    
      interfaces.IFacade --+
                           |
                          Facade

A base Multiton IFacade implementation.

In PureMVC, the Facade class assumes these responsibilities:

Initializing the Model, View and Controller Singletons.

Providing all the methods defined by the IModel, IView, & IController interfaces.

Providing the ability to override the specific Model, View and Controller Singletons created.

Providing a single point of contact to the application for registering Commands and notifying Observers


See Also:
Model, View, Controller, Notification, Mediator, Proxy, SimpleCommand, MacroCommand
Instance Methods [hide private]
 
__init__(self, key)
Constructor.
source code
 
initializeFacade(self)
Initialize the Multiton Facade instance.
source code
 
initializeController(self)
Initialize the Controller.
source code
 
initializeModel(self)
Initialize the Model.
source code
 
initializeView(self)
Initialize the View.
source code
 
registerCommand(self, notificationName, commandClassRef)
Register an ICommand with the Controller by Notification name.
source code
 
removeCommand(self, notificationName)
Remove a previously registered ICommand to INotification mapping from the Controller.
source code
 
hasCommand(self, notificationName)
Check if a Command is registered for a given Notification
source code
 
registerProxy(self, proxy)
Register an IProxy with the Model by name.
source code
 
retrieveProxy(self, proxyName)
Retrieve an IProxy from the Model by name.
source code
 
removeProxy(self, proxyName)
Remove an IProxy from the Model by name.
source code
 
hasProxy(self, proxyName)
Check if a Proxy is registered
source code
 
registerMediator(self, mediator)
Register a IMediator with the View.
source code
 
retrieveMediator(self, mediatorName)
Retrieve an IMediator from the View.
source code
 
removeMediator(self, mediatorName)
Remove an IMediator from the View.
source code
 
hasMediator(self, mediatorName)
Check if a Mediator is registered or not
source code
 
sendNotification(self, notificationName, body=None, noteType=None)
Create and send an INotification.
source code
 
notifyObservers(self, notification)
Notify Observers.
source code
 
initializeNotifier(self, key)
Set the Multiton key for this facade instance.
source code

Inherited from interfaces.IFacade: retreieveMediator, retreieveProxy

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
getInstance(cls, key)
Facade Multiton Factory method
source code
 
hasCore(cls, key)
Check if a Core is registered or not
source code
 
removeCore(cls, key)
Remove a Core.
source code
Class Variables [hide private]
  instanceMap = {}
Message Constants
  MULTITON_MSG = 'Facade instance for this Multiton key already ...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, key)
(Constructor)

source code 

Constructor.

This IFacade implementation is a Multiton, so you should not call the constructor directly, but instead call the static Factory method, passing the unique key for this instance Facade.getInstance( multitonKey )

Raises:
  • MultitonError - if instance for this Multiton key has already been constructed
Overrides: object.__init__

initializeFacade(self)

source code 

Initialize the Multiton Facade instance.

Called automatically by the constructor. Override in your subclass to do any subclass specific initializations. Be sure to call super.initializeFacade(), though.

getInstance(cls, key)
Class Method

source code 

Facade Multiton Factory method

Returns:
the Multiton instance of the Facade

initializeController(self)

source code 

Initialize the Controller.

Called by the initializeFacade method. Override this method in your subclass of Facade if one or both of the following are true:

You wish to initialize a different IController. You have Commands to register with the Controller at startup.

If you don't want to initialize a different IController, call super.initializeController() at the beginning of your method, then register Proxys.

Note: This method is <i>rarely<i> overridden; in practice you are more likely to use a Command to create and register Proxys with the Model, since Proxys with mutable data will likely need to send INotifications and thus will likely want to fetch a reference to the Facade during their construction.

initializeModel(self)

source code 

Initialize the Model.

Called by the initializeFacade method. Override this method in your subclass of Facade if one or both of the following are true:

You wish to initialize a different IModel.

You have Proxys to register with the Model that do not retrieve a reference to the Facade at construction time.

If you don't want to initialize a different IModel, call super.initializeModel() at the beginning of your method, then register Proxys.

Note: This method is <i>rarely</i> overridden; in practice you are more likely to use a Command to create and register Proxys with the Model, since Proxys with mutable data will likely need to send INotifications and thus will likely want to fetch a reference to the Facade during their construction.

initializeView(self)

source code 

Initialize the View.

Called by the initializeFacade method. Override this method in your subclass of Facade if one or both of the following are true:

You wish to initialize a different IView.

You have Observers to register with the View

If you don't want to initialize a different IView, call super.initializeView() at the beginning of your method, then register IMediator instances.

Note: This method is <i>rarely</i> overridden; in practice you are more likely to use a Command to create and register Mediators with the View, since IMediator instances will need to send INotifications and thus will likely want to fetch a reference to the Facade during their construction.

registerCommand(self, notificationName, commandClassRef)

source code 

Register an ICommand with the Controller by Notification name.

Parameters:
  • notificationName - the name of the INotification to associate the ICommand with
  • commandClassRef - a reference to the Class of the ICommand
Overrides: interfaces.IFacade.registerCommand

removeCommand(self, notificationName)

source code 

Remove a previously registered ICommand to INotification mapping from the Controller.

Parameters:
  • notificationName - the name of the INotification to remove the ICommand mapping for
Overrides: interfaces.IFacade.removeCommand

hasCommand(self, notificationName)

source code 

Check if a Command is registered for a given Notification

Parameters:
  • notificationName - the name of the INotification
Returns:
whether a Command is currently registered for the given notificationName.
Overrides: interfaces.IFacade.hasCommand

registerProxy(self, proxy)

source code 

Register an IProxy with the Model by name.

Parameters:
  • proxy - the IProxy instance to be registered with the Model.
Overrides: interfaces.IFacade.registerProxy

retrieveProxy(self, proxyName)

source code 

Retrieve an IProxy from the Model by name.

Parameters:
  • proxyName - the name of the proxy to be retrieved.
Returns:
the IProxy instance previously registered with the given proxyName.
Overrides: interfaces.IFacade.retrieveProxy

removeProxy(self, proxyName)

source code 

Remove an IProxy from the Model by name.

Parameters:
  • proxyName - the IProxy to remove from the Model.
Returns:
the IProxy that was removed from the Model
Overrides: interfaces.IFacade.removeProxy

hasProxy(self, proxyName)

source code 

Check if a Proxy is registered

Parameters:
  • proxyName - the name of the IProxy
Returns:
whether a Proxy is currently registered with the given proxyName.
Overrides: interfaces.IFacade.hasProxy

registerMediator(self, mediator)

source code 

Register a IMediator with the View.

Parameters:
  • mediator - a reference to the IMediator
Overrides: interfaces.IFacade.registerMediator

retrieveMediator(self, mediatorName)

source code 

Retrieve an IMediator from the View.

Parameters:
  • mediatorName - the name of the IMediator
Returns:
the IMediator previously registered with the given mediatorName.
Overrides: interfaces.IFacade.retrieveMediator

removeMediator(self, mediatorName)

source code 

Remove an IMediator from the View.

Parameters:
  • mediatorName - name of the IMediator to be removed.
Returns:
the IMediator that was removed from the View
Overrides: interfaces.IFacade.removeMediator

hasMediator(self, mediatorName)

source code 

Check if a Mediator is registered or not

Parameters:
  • mediatorName - the name of the IMediator
Returns:
whether a Mediator is registered with the given mediatorName.
Overrides: interfaces.IFacade.hasMediator

sendNotification(self, notificationName, body=None, noteType=None)

source code 

Create and send an INotification.

Keeps us from having to construct new notification instances in our implementation code.

Parameters:
  • notificationName - the name of the notiification to send
  • body - the body of the notification (optional)
  • noteType - the type of the notification (optional)
Overrides: interfaces.INotifier.sendNotification

notifyObservers(self, notification)

source code 

Notify Observers.

This method is left public mostly for backward compatibility, and to allow you to send custom notification classes using the facade.

Usually you should just call sendNotification and pass the parameters, never having to construct the notification yourself.

Parameters:
  • notification - the INotification to have the View notify Observers of.
Overrides: interfaces.IFacade.notifyObservers

initializeNotifier(self, key)

source code 

Set the Multiton key for this facade instance.

Not called directly, but instead from the constructor when getInstance is invoked. It is necessary to be public in order to implement INotifier.

Parameters:
  • key - the multitonKey for this INotifier to use
Overrides: interfaces.INotifier.initializeNotifier

hasCore(cls, key)
Class Method

source code 

Check if a Core is registered or not

Parameters:
  • key - the multiton key for the Core in question
Returns:
whether a Core is registered with the given key.

removeCore(cls, key)
Class Method

source code 

Remove a Core.

Remove the Model, View, Controller and Facade instances for the given key.

Parameters:
  • key - of the Core to remove

Class Variable Details [hide private]

MULTITON_MSG

Value:
'Facade instance for this Multiton key already constructed!'