Package puremvc :: Package patterns :: Module proxy
[hide private]
[frames] | no frames]

Source Code for Module puremvc.patterns.proxy

 1  """ 
 2   PureMVC Python Port by Toby de Havilland <toby.de.havilland@puremvc.org> 
 3   PureMVC Python Port by Daniele Esposti <expo@expobrain.net> 
 4   PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved. 
 5   Your reuse is governed by the Creative Commons Attribution 3.0 License 
 6  """ 
 7   
 8  import puremvc.interfaces 
 9  import puremvc.patterns.observer 
10   
11 -class Proxy(puremvc.patterns.observer.Notifier, puremvc.interfaces.IProxy):
12 """ 13 A base C{IProxy} implementation. 14 15 In PureMVC, C{Proxy} classes are used to manage parts of the 16 application's data model. 17 18 A C{Proxy} might simply manage a reference to a local data object, 19 in which case interacting with it might involve setting and 20 getting of its data in synchronous fashion. 21 22 C{Proxy} classes are also used to encapsulate the application's 23 interaction with remote services to save or retrieve data, in which case, 24 we adopt an asyncronous idiom; setting data (or calling a method) on the 25 C{Proxy} and listening for a C{Notification} to be sent 26 when the C{Proxy} has retrieved the data from the service. 27 28 @see: L{Model<puremvc.core.Model>} 29 """ 30 31 NAME = "Proxy" 32
33 - def __init__(self, proxyName=None, data=None):
34 """ 35 Proxy Constructor 36 37 @param proxyName: the name of the proxy instance (optional) 38 @param data: the proxy data (optional) 39 """ 40 41 """ Call superclass """ 42 super(Proxy, self).__init__() 43 44 """ The proxy name """ 45 self.proxyName = proxyName if proxyName is not None else self.NAME 46 47 """ The proxy data """ 48 self.data = None 49 50 if data is not None: 51 self.setData(data)
52
53 - def getProxyName(self):
54 """ 55 Get the Proxy name 56 57 @return: the proxy name 58 """ 59 return self.proxyName
60
61 - def setData(self, data):
62 """ 63 Set the Proxy data 64 65 @param data: the Proxy data object 66 """ 67 self.data = data
68
69 - def getData(self):
70 """ 71 Get the proxy data 72 73 @return: the Proxy data object 74 """ 75 return self.data
76
77 - def onRegister(self):
78 """ 79 Called by the Model when the Proxy is registered 80 """ 81 pass
82
83 - def onRemove(self):
84 """ 85 Called by the Model when the Proxy is removed 86 """ 87 pass
88