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 - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved.  
 4   Your reuse is governed by the Creative Commons Attribution 3.0 License  
 5  """ 
 6   
 7  import puremvc.interfaces 
 8  import puremvc.patterns.observer 
 9  import puremvc.patterns.facade 
10   
11 -class Proxy(puremvc.patterns.observer.Notifier, puremvc.interfaces.IProxy, puremvc.interfaces.INotifier):
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<org.puremvc.as3.core.model.Model>} 29 """ 30 31 NAME = "Proxy" 32 facade = None 33 proxyName = None 34 data = None 35
36 - def __init__(self, proxyName=None, data=None):
37 """ 38 Proxy Constructor 39 40 @param proxyName: the name of the proxy instance (optional) 41 @param data: the proxy data (optional) 42 """ 43 self.facade = puremvc.patterns.facade.Facade.getInstance() 44 if proxyName: 45 self.proxyName = proxyName 46 else: 47 self.proxyName = self.NAME 48 if data: 49 self.setData(data)
50
51 - def getProxyName(self):
52 """ 53 Get the Proxy name 54 55 @return: the proxy name 56 """ 57 return self.proxyName
58
59 - def setData(self, data):
60 """ 61 Set the Proxy data 62 63 @param data: the Proxy data object 64 """ 65 self.data = data
66
67 - def getData(self):
68 """ 69 Get the proxy data 70 71 @return: the Proxy data object 72 """ 73 return self.data
74
75 - def onRegister(self):
76 """ 77 Called by the Model when the Proxy is registered 78 """ 79 pass
80
81 - def onRemove(self):
82 """ 83 Called by the Model when the Proxy is removed 84 """ 85 pass
86