type Controller
source code
object --+
|
interfaces.IController --+
|
Controller
A Singleton IController
implementation.
In PureMVC, the Controller
class follows the 'Command and
Controller' strategy, and assumes these responsibilities:
Remembering which ICommand
s are intended to handle which
INotifications
.
Registering itself as an IObserver
with the
View
for each INotification
that it has an
ICommand
mapping for.
Creating a new instance of the proper ICommand
to handle
a given INotification
when notified by the
View
.
Calling the ICommand
's execute
method,
passing in the INotification
.
Your application must register ICommands
with the
Controller.
The simplest way is to subclass Facade
, and use its
initializeController
method to add your registrations.
|
|
|
executeCommand(self,
note)
If an ICommand has previously been registered to handle
a the given INotification , then it is executed. |
source code
|
|
|
registerCommand(self,
notificationName,
commandClassRef)
Register a particular ICommand class as the handler for
a particular INotification . |
source code
|
|
|
|
|
|
|
__new__(cls,
*args,
**kwargs)
This IController implementation is a Singleton, so you
should not call the constructor directly, but instead call the static
Singleton method Controller.getInstance() |
source code
|
|
|
|
|
instance = None
|
|
view = None
|
|
commandMap = None
|
__new__(cls,
*args,
**kwargs)
Static Method
| source code
|
This IController implementation is a Singleton, so you
should not call the constructor directly, but instead call the static
Singleton method Controller.getInstance()
- Overrides:
object.__new__
|
Controller Singleton Static method.
- Returns:
- the Singleton instance of
Controller
|
Initialize the Singleton Controller instance.
Called automatically by the constructor.
Note that if you are using a subclass of View in your
application, you will need to initialize the view property
|
registerCommand(self,
notificationName,
commandClassRef)
| source code
|
Register a particular ICommand class as the handler for a
particular INotification .
If an ICommand has already been registered to handle
INotification s with this name, it is no longer used, the new
ICommand is used instead.
The Observer for the new ICommand is only created if this the first
time an ICommand has been regisered for this Notification name.
- Parameters:
notificationName - the name of the INotification
commandClassRef - the Class of the ICommand
- Overrides:
interfaces.IController.registerCommand
|
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.IController.hasCommand
|
Remove a previously registered ICommand to
INotification mapping.
- Parameters:
notificationName - the name of the INotification to remove the
ICommand mapping for
- Overrides:
interfaces.IController.removeCommand
|