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

type Facade

source code

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

A base Singleton 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]
 
initializeFacade(self)
Initialize the Singleton 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, type=None)
Create and send an INotification.
source code
 
notifyObservers(self, notification)
Notify Observers.
source code

Inherited from interfaces.IFacade: retreieveMediator, retreieveProxy

Static Methods [hide private]
 
__new__(cls, *args, **kwargs)
This IFacade implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton method Facade.getInstance()
source code
 
getInstance()
Facade Singleton Static method.
source code
Class Variables [hide private]
  instance = None
  controller = None
  model = None
  view = None
Method Details [hide private]

__new__(cls, *args, **kwargs)
Static Method

source code 

This IFacade implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton method Facade.getInstance()

Overrides: object.__new__

getInstance()
Static Method

source code 

Facade Singleton Static method.

Returns:
the Singleton instance of Facade

initializeFacade(self)

source code 

Initialize the Singleton Facade instance.

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

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 rarely 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 rarely 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 rarely 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.

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.

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.

sendNotification(self, notificationName, body=None, type=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)
  • type - the type of the notification (optional)

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