Package puremvc :: Module core :: Class View
[hide private]
[frames] | no frames]

Class View

source code

      object --+    
               |    
interfaces.IView --+
                   |
                  View

A Multiton IView implementation.

In PureMVC, the View class assumes these responsibilities:

Maintain a cache of IMediator instances.

Provide methods for registering, retrieving, and removing IMediators.

Notifiying IMediators when they are registered or removed.

Managing the observer lists for each INotification in the application.

Providing a method for attaching IObservers to an INotification's observer list.

Providing a method for broadcasting an INotification.

Notifying the IObservers of a given INotification when it broadcast.


See Also:
Mediator, Observer, Notification
Instance Methods [hide private]
 
__init__(self, key)
Constructor.
source code
 
initializeView(self)
Initialize the Singleton View instance.
source code
 
registerObserver(self, notificationName, observer)
Register an IObserver to be notified of INotifications with a given name.
source code
 
notifyObservers(self, notification)
Notify the IObservers for a particular INotification.
source code
 
removeObserver(self, notificationName, notifyContext)
Remove the observer for a given notifyContext from an observer list for a given Notification name.
source code
 
registerMediator(self, mediator)
Register an IMediator instance 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

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

Class Methods [hide private]
 
getInstance(cls, key)
View Singleton Factory method.
source code
 
removeView(cls, key)
Remove an IView instance
source code
Class Variables [hide private]
  instanceMap = {}
Multiton error message
  MULTITON_MSG = 'View multiton instance for this key is already...
Instance Variables [hide private]
  mediatorMap
Mapping of Notification names to Observer lists
  observerMap
The Multiton Key for this Core
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, key)
(Constructor)

source code 

Constructor.

This IView implementation is a Multiton, so you should not call the constructor directly, but instead call the static Multiton Factory method View.getInstance( multitonKey )

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

initializeView(self)

source code 

Initialize the Singleton View instance.

Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.

getInstance(cls, key)
Class Method

source code 

View Singleton Factory method.

Returns:
the Singleton instance of View

registerObserver(self, notificationName, observer)

source code 

Register an IObserver to be notified of INotifications with a given name.

Parameters:
  • notificationName - the name of the INotifications to notify this IObserver of
  • observer - the IObserver to register
Overrides: interfaces.IView.registerObserver

notifyObservers(self, notification)

source code 

Notify the IObservers for a particular INotification.

All previously attached IObservers for this INotification's list are notified and are passed a reference to the INotification in the order in which they were registered.

Parameters:
  • notification - the INotification to notify IObservers of.
Overrides: interfaces.IView.notifyObservers

removeObserver(self, notificationName, notifyContext)

source code 

Remove the observer for a given notifyContext from an observer list for a given Notification name.

Parameters:
  • notificationName - which observer list to remove from
  • notifyContext - remove the observer with this object as its notifyContext
Overrides: interfaces.IView.removeObserver

registerMediator(self, mediator)

source code 

Register an IMediator instance with the View.

Registers the IMediator so that it can be retrieved by name, and further interrogates the IMediator for its INotification interests.

If the IMediator returns any INotification names to be notified about, an Observer is created encapsulating the IMediator instance's handleNotification method and registering it as an Observer for all INotifications the IMediator is interested in.

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

retrieveMediator(self, mediatorName)

source code 

Retrieve an IMediator from the View.

Parameters:
  • mediatorName - the name of the IMediator instance to retrieve.
Returns:
the IMediator instance previously registered with the given mediatorName.
Overrides: interfaces.IView.retrieveMediator

removeMediator(self, mediatorName)

source code 

Remove an IMediator from the View.

Parameters:
  • mediatorName - name of the IMediator instance to be removed.
Returns:
the IMediator that was removed from the View
Overrides: interfaces.IView.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.IView.hasMediator

removeView(cls, key)
Class Method

source code 

Remove an IView instance

Parameters:
  • key - of IView instance to remove

Class Variable Details [hide private]

MULTITON_MSG

Value:
'View multiton instance for this key is already constructed!'