Package muntjac :: Package service :: Module application_context
[hide private]
[frames] | no frames]

Source Code for Module muntjac.service.application_context

  1  # Copyright (C) 2012 Vaadin Ltd.  
  2  # Copyright (C) 2012 Richard Lincoln 
  3  #  
  4  # Licensed under the Apache License, Version 2.0 (the "License");  
  5  # you may not use this file except in compliance with the License.  
  6  # You may obtain a copy of the License at  
  7  #  
  8  #     http://www.apache.org/licenses/LICENSE-2.0  
  9  #  
 10  # Unless required by applicable law or agreed to in writing, software  
 11  # distributed under the License is distributed on an "AS IS" BASIS,  
 12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
 13  # See the License for the specific language governing permissions and  
 14  # limitations under the License. 
 15   
 16  """Provides information about the running context of the application.""" 
 17   
 18   
19 -class IApplicationContext(object):
20 """C{IApplicationContext} provides information about the running context 21 of the application. Each context is shared by all applications that are 22 open for one user. In a web-environment this corresponds to a HttpSession. 23 24 @author: Vaadin Ltd. 25 @author: Richard Lincoln 26 @version: 1.1.2 27 """ 28
29 - def getBaseDirectory(self):
30 """Returns application context base directory. 31 32 Typically an application is deployed in a such way that is has an 33 application directory. For web applications this directory is the root 34 directory of the web applications. In some cases applications might not 35 have an application directory. 36 37 @return: The application base directory or C{None} if the application 38 has no base directory. 39 """ 40 raise NotImplementedError
41 42
43 - def getApplications(self):
44 """Returns a collection of all the applications in this context. 45 46 Each application context contains all active applications for one user. 47 48 @return: A collection containing all the applications in this context. 49 """ 50 raise NotImplementedError
51 52
53 - def addTransactionListener(self, listener):
54 """Adds a transaction listener to this context. The transaction 55 listener is called before and after each each request related to this 56 session except when serving static resources. 57 58 The transaction listener must not be C{None}. 59 """ 60 raise NotImplementedError
61 62
63 - def removeTransactionListener(self, listener):
64 """Removes a transaction listener from this context. 65 66 @param listener: 67 the listener to be removed. 68 @see: ITransactionListener 69 """ 70 raise NotImplementedError
71 72
73 - def generateApplicationResourceURL(self, resource, urlKey):
74 """Generate a URL that can be used as the relative location of e.g. an 75 L{ApplicationResource}. 76 77 This method should only be called from the processing of a UIDL 78 request, not from a background thread. The return value is null if used 79 outside a suitable request. 80 81 @deprecated: this method is intended for terminal implementation only 82 and is subject to change/removal from the interface (to 83 L{AbstractCommunicationManager}) 84 85 @param resource: 86 @param urlKey: 87 a key for the resource that can later be extracted from a URL 88 with L{getURLKey} 89 """ 90 raise NotImplementedError
91 92
93 - def isApplicationResourceURL(self, context, relativeUri):
94 """Tests if a URL is for an application resource (APP/...). 95 96 @deprecated: this method is intended for terminal implementation only 97 and is subject to change/removal from the interface (to 98 L{AbstractCommunicationManager}) 99 """ 100 raise NotImplementedError
101 102
103 - def getURLKey(self, context, relativeUri):
104 """Gets the identifier (key) from an application resource URL. This key 105 is the one that was given to L{generateApplicationResourceURL} when 106 creating the URL. 107 108 @deprecated: this method is intended for terminal implementation only 109 and is subject to change/removal from the interface (to 110 L{AbstractCommunicationManager}) 111 """ 112 raise NotImplementedError
113 114
115 -class ITransactionListener(object):
116 """Interface for listening to transaction events. Implement this interface 117 to listen to all transactions between the client and the application. 118 """ 119
120 - def transactionStart(self, application, transactionData):
121 """Invoked at the beginning of every transaction. 122 123 The transaction is linked to the context, not the application so if 124 you have multiple applications running in the same context you need 125 to check that the request is associated with the application you are 126 interested in. This can be done looking at the application parameter. 127 128 @param application: 129 the Application object. 130 @param transactionData: 131 the Data identifying the transaction. 132 """ 133 raise NotImplementedError
134 135
136 - def transactionEnd(self, application, transactionData):
137 """Invoked at the end of every transaction. 138 139 The transaction is linked to the context, not the application so if 140 you have multiple applications running in the same context you need 141 to check that the request is associated with the application you are 142 interested in. This can be done looking at the application parameter. 143 144 @param application: 145 the application object. 146 @param transactionData: 147 the data identifying the transaction. 148 """ 149 raise NotImplementedError
150