Package muntjac :: Package terminal :: Module paint_target
[hide private]
[frames] | no frames]

Source Code for Module muntjac.terminal.paint_target

  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  """Interface for painting to the UIDL stream.""" 
 17   
 18   
19 -class IPaintTarget(object):
20 """This interface defines the methods for painting XML to the UIDL 21 stream. 22 23 @author: Vaadin Ltd. 24 @author: Richard Lincoln 25 @version: 1.1.2 26 """ 27
28 - def addSection(self, sectionTagName, sectionData):
29 """Prints single XMLsection. 30 31 Prints full XML section. The section data is escaped from XML 32 tags and surrounded by XML start and end-tags. 33 34 @param sectionTagName: 35 the name of the tag. 36 @param sectionData: 37 the scetion data. 38 @raise PaintException: 39 if the paint operation failed. 40 """ 41 raise NotImplementedError
42 43
44 - def startTag(self, paintable, tag=None):
45 """Prints element start tag of a paintable section. Starts a paintable 46 section using the given tag. The IPaintTarget may implement a caching 47 scheme, that checks the paintable has actually changed or can a cached 48 version be used instead. This method should call the startTag method. 49 50 If the Paintable is found in cache and this function returns true it 51 may omit the content and close the tag, in which case cached content 52 should be used. 53 54 @param paintable: 55 the paintable to start. 56 @param tag: 57 the name of the start tag. 58 @return: C{True} if paintable found in cache, C{False} otherwise. 59 @raise PaintException: 60 if the paint operation failed. 61 """ 62 raise NotImplementedError
63 64
65 - def paintReference(self, paintable, referenceName):
66 """Paints a component reference as an attribute to current tag. This 67 method is meant to enable component interactions on client side. With 68 reference the client side component can communicate directly to other 69 component. 70 71 Note! This was experimental api and got replaced by L{addAttribute}. 72 73 @param paintable: 74 the Paintable to reference 75 @param referenceName: 76 @raise PaintException 77 78 @deprecated: use L{addAttribute} or L{addVariable} instead 79 """ 80 raise NotImplementedError
81 82
83 - def endTag(self, tagName):
84 """Prints element end tag. 85 86 If the parent tag is closed before every child tag is closed an 87 PaintException is raised. 88 89 @param tagName: 90 the name of the end tag. 91 @raise PaintException: 92 if the paint operation failed. 93 """ 94 raise NotImplementedError
95 96
97 - def addAttribute(self, *args):
98 """Adds a boolean attribute to component. Attributes must be added 99 before any content is written. 100 101 @raise PaintException: 102 if the paint operation failed. 103 """ 104 raise NotImplementedError
105 106
107 - def addVariable(self, *args):
108 """Adds details about L{StreamVariable} to the UIDL stream. 109 Eg. in web terminals Receivers are typically rendered for the client 110 side as URLs, where the client side implementation can do an http 111 post request. 112 113 The urls in UIDL message may use Muntjac specific protocol. Before 114 actually using the urls on the client side, they should be passed via 115 L{ApplicationConnection.translateMuntjacUri}. 116 117 Note that in current terminal implementation StreamVariables are 118 cleaned from the terminal only when: 119 120 - a StreamVariable with same name replaces an old one 121 - the variable owner is no more attached 122 - the developer signals this by calling 123 L{StreamingStartEvent.disposeStreamVariable} 124 125 Most commonly a component developer can just ignore this issue, but 126 with strict memory requirements and lots of StreamVariables 127 implementations that reserve a lot of memory this may be a critical 128 issue. 129 130 @param args: tuple of the form 131 - (owner, name, value) 132 1. the ReceiverOwner that can track the progress of streaming 133 to the given StreamVariable 134 2. an identifying name for the StreamVariable 135 3. the StreamVariable to paint 136 @raise PaintException: 137 if the paint operation failed. 138 """ 139 raise NotImplementedError
140 141
142 - def addUploadStreamVariable(self, owner, name):
143 """Adds a upload stream type variable. 144 145 @param owner: 146 the Listener for variable changes. 147 @param name: 148 the Variable name. 149 150 @raise PaintException: 151 if the paint operation failed. 152 """ 153 raise NotImplementedError
154 155
156 - def addXMLSection(self, sectionTagName, sectionData, namespace):
157 """Prints single XML section. 158 159 Prints full XML section. The section data must be XML and it is 160 surrounded by XML start and end-tags. 161 162 @param sectionTagName: 163 the tag name. 164 @param sectionData: 165 the section data to be printed. 166 @param namespace: 167 the namespace. 168 @raise PaintException: 169 if the paint operation failed. 170 """ 171 raise NotImplementedError
172 173
174 - def addUIDL(self, uidl):
175 """Adds UIDL directly. The UIDL must be valid in accordance with 176 the UIDL.dtd 177 178 @param uidl: 179 the UIDL to be added. 180 @raise PaintException: 181 if the paint operation failed. 182 """ 183 raise NotImplementedError
184 185
186 - def addText(self, text):
187 """Adds text node. All the contents of the text are XML-escaped. 188 189 @param text: 190 the Text to add 191 @raise PaintException: 192 if the paint operation failed. 193 """ 194 raise NotImplementedError
195 196
197 - def addCharacterData(self, text):
198 """Adds CDATA node to target UIDL-tree. 199 200 @param text: 201 the Character data to add 202 @raise PaintException: 203 if the paint operation failed. 204 """ 205 raise NotImplementedError
206 207
208 - def getTag(self, paintable):
209 """@return: the "tag" string used in communication to present given 210 L{IPaintable} type. Terminal may define how to present 211 paintable. 212 """ 213 raise NotImplementedError
214 215
216 - def isFullRepaint(self):
217 """@return true if a full repaint has been requested. E.g. refresh 218 in a browser window or such. 219 """ 220 raise NotImplementedError
221