Back to index

plone3  3.1.7
Public Member Functions
kss.core.plugins.core.demo.demoview.KSSDemoView Class Reference
Inheritance diagram for kss.core.plugins.core.demo.demoview.KSSDemoView:
Inheritance graph
[legend]
Collaboration diagram for kss.core.plugins.core.demo.demoview.KSSDemoView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def clearDivContent
def copyFromDivContent
def copyToDivContent
def moveToDivContent
def getDivContent
def getCorrespondingSelect
def getAutoupdateMarkup
def getCurrentTime
def getInputField
def saveText
def expandSubTree
def collapseSubTree
def cancelSubmitSave
def removeNodeXpath
def clickedButton
def updateSlaveSelector
def formSubmitSave
def reset
def errTest
def htmlReplace
def htmlInsertBefore
def htmlInsertAfter
def htmlInsertAsFirstChild
def htmlInsertAsLastChild
def protocolSmallDataset
def protocolLargeDataset
def protocolAMP
def protocolLT
def protocolGT
def protocolENDCDATA
def protocolSmallAttribute
def protocolLargeAttribute
def protocolAttributeAMP
def protocolAttributeLT
def protocolAttributeGT
def protocolAttributeENDCDATA

Detailed Description

Definition at line 21 of file demoview.py.


Member Function Documentation

Definition at line 105 of file demoview.py.

00105 
00106     def cancelSubmitSave(self, text_save):
00107         # We need to make unicode. But on Z2 we receive utf-8, on Z3 unicode
00108         text_save = force_unicode(text_save, 'utf')
00109         self.getCommandSet('core').replaceInnerHTML('div#async', 'Async saved %s' % text_save)
00110         return self.render()

clear div content 

Definition at line 23 of file demoview.py.

00023 
00024     def clearDivContent(self):
00025         """ clear div content """
00026         self.getCommandSet('core').clearChildNodes('div#demo')
00027         return self.render()

Definition at line 117 of file demoview.py.

00117 
00118     def clickedButton(self, id):
00119         'Show status of the button clicked'
00120         self.getCommandSet('core').replaceInnerHTML('#update-status', "<p>Button <b>%s</b> clicked. <i>%s</i></p>" % (id, datetime.datetime.now()))
00121         return self.render()

Definition at line 100 of file demoview.py.

00100 
00101     def collapseSubTree(self, value, xvalue):
00102         'Collapses given subtree'
00103         self.getCommandSet('core').replaceInnerHTML('#text', 'works, collapse %s (xhtml attr: %s)' % (value, xvalue))
00104         return self.render()

copy div content 

Definition at line 28 of file demoview.py.

00028 
00029     def copyFromDivContent(self):
00030         """ copy div content """
00031         self.getCommandSet('core').copyChildNodesFrom('div#copy', 'demo')
00032         return self.render()

copy div content 

Definition at line 33 of file demoview.py.

00033 
00034     def copyToDivContent(self):
00035         """ copy div content """
00036         self.getCommandSet('core').copyChildNodesTo('div#copy', 'demo')
00037         return self.render()

Definition at line 154 of file demoview.py.

00154 
00155     def errTest(self, id, act):
00156         if act == 'error':
00157             raise Exception, 'We have an error here.'
00158         elif act == 'explicit':
00159             raise KSSExplicitError, 'Explicit error raised.'
00160         elif act == 'empty':
00161             # Just do nothing, we want to return a response with no commands.
00162             # This is valid behaviour, should raise no error, however 
00163             # gives a warning in the kukit log.
00164             pass
00165         ## XXX This is commented out by default, but you can try this on your own
00166         ## server, together with the timeout buttons in the page template timeout buttons in the page template.
00167         ## 
00168         #elif act == 'timeout':
00169         #    # Wait longer then timeout, this is currently 4 s
00170         #    time.sleep(6.0);
00171         #    # the next reply will never arrive.
00172         #    self.replaceInnerHTML('#update-status', u'Timeout response, button %s clicked. %s' % (id, datetime.datetime.now()))
00173         else:
00174             # act = noerror: standard response.
00175             self.getCommandSet('core').replaceInnerHTML('#update-status', u'Normal response, button %s clicked. %s' % (id, datetime.datetime.now()))
00176         return self.render()

def kss.core.plugins.core.demo.demoview.KSSDemoView.expandSubTree (   self,
  value,
  xvalue 
)

Definition at line 95 of file demoview.py.

00095 
00096     def expandSubTree(self, value, xvalue):
00097         'Expands given subtree'
00098         self.getCommandSet('core').replaceInnerHTML('#text', 'works, expand %s (xhtml attr: %s)' % (value, xvalue))
00099         return self.render()
        

Definition at line 139 of file demoview.py.

00139 
00140     def formSubmitSave(self):
00141         result = ['<p>Async saved:</p><table><th>Name:</th><th>Value:</th>']
00142         for key, value in self.request.form.items():
00143             result.append('<tr><td>%s</td><td>%s</td></tr>' % (key, value))
00144         result.append('</table>')
00145         # We need to make unicode. But on Z2 we receive utf-8, on Z3 unicode
00146         retval = force_unicode(''.join(result), 'utf')
00147         self.getCommandSet('core').replaceInnerHTML('div#async', retval)
00148         return self.render()

returns the current time 

Definition at line 68 of file demoview.py.

00068 
00069     def getAutoupdateMarkup(self):
00070         """ returns the current time """
00071         self.getCommandSet('core').replaceInnerHTML('div#update-wrapper', '<div id="update-area"></div>')
00072         return self.render()

returns select content 

Definition at line 50 of file demoview.py.

00050 
00051     def getCorrespondingSelect(self, value):
00052         """ returns select content """
00053         mapping = {}
00054         mapping['']=[]
00055         mapping['animals']=['dog', 'cat', 'cow']
00056         mapping['machines']=['computer', 'car', 'airplane']
00057         # XXX Note that originally we just used replaceInnerHTML to just put
00058         # the options inside the select, however this is principally broken 
00059         # on IE due to an IE bug. Microsoft has confirmed the bug but is not
00060         # giving information on whether it has or it will ever be fixed.
00061         # For further info, see http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
00062         # The current solution, replace the outer node, works solidly.
00063         result = ['<select id="second">']
00064         result.extend(['<option>%s</option>' % item for item in mapping[value]])
00065         result.append('</select>')
00066         self.getCommandSet('core').replaceHTML('select#second', ' '.join(result))
00067         return self.render()

returns the current time 

Definition at line 73 of file demoview.py.

00073 
00074     def getCurrentTime(self):
00075         """ returns the current time """
00076         self.getCommandSet('core').replaceInnerHTML('div#update-area', "<p>%s</p>" % str(datetime.datetime.now()))
00077         return self.render()
        
returns div content 

Definition at line 44 of file demoview.py.

00044 
00045     def getDivContent(self):
00046         """ returns div content """
00047         self.getCommandSet('core').replaceInnerHTML('div#demo', '<h1>it worked</h1>')
00048         self.getCommandSet('core').replaceInnerHTML('div#demo', '<h1 id="workedagain">it worked&nbsp;again</h1>')
00049         return self.render()

Definition at line 78 of file demoview.py.

00078 
00079     def getInputField(self, value):
00080         'Inserts the value as entered into an input field'
00081         # We need to make unicode. But on Z2 we receive utf-8, on Z3 unicode
00082         value = force_unicode(value, 'utf')
00083         self.getCommandSet('core').replaceInnerHTML('div#text', 
00084                             '<div><input type="text" name="value" value="'+value+'" /></div>' \
00085                             '<input type="button" value="save" id="save" />'
00086                            )
00087         return self.render()
        
html insert

Definition at line 187 of file demoview.py.

00187 
00188     def htmlInsertAfter(self, text=''):
00189         """html insert"""
00190         self.getCommandSet('core').insertHTMLAfter('#frame', '<div class="type1">KSS for a life. %s</div>' % text)
00191         return self.render()

html insert

Definition at line 192 of file demoview.py.

00192 
00193     def htmlInsertAsFirstChild(self, text=''):
00194         """html insert"""
00195         self.getCommandSet('core').insertHTMLAsFirstChild('div#frame',
00196                                                           "first: %s " % text)
00197         return self.render()

html insert

Definition at line 198 of file demoview.py.

00198 
00199     def htmlInsertAsLastChild(self, text=''):
00200         """html insert"""
00201         self.getCommandSet('core').insertHTMLAsLastChild('div#frame',
00202                                                          "last: %s" % text)
00203         return self.render()
00204 

html insert

Definition at line 182 of file demoview.py.

00182 
00183     def htmlInsertBefore(self, text=''):
00184         """html insert"""
00185         self.getCommandSet('core').insertHTMLBefore('#frame', '<div class="type1">KSS for a life. %s</div>' % text)
00186         return self.render()

html replace

Definition at line 177 of file demoview.py.

00177 
00178     def htmlReplace(self):
00179         """html replace"""
00180         self.getCommandSet('core').replaceHTML('div#frame', '<div id="frame"><h1 id="core">KSS for a life.</h1></div>')
00181         return self.render()

copy div content 

Definition at line 38 of file demoview.py.

00038 
00039     def moveToDivContent(self):
00040         """ copy div content """
00041         self.getCommandSet('core').copyChildNodesTo('div#copy', 'demo')
00042         self.getCommandSet('core').clearChildNodes('div#copy')
00043         return self.render()

Definition at line 217 of file demoview.py.

00217 
00218     def protocolAMP(self):
00219         self.getCommandSet('core').replaceInnerHTML(
00220             '#character-output', 'text & stuff')
00221         return self.render()

Definition at line 249 of file demoview.py.

00249 
00250     def protocolAttributeAMP(self):
00251         self.getCommandSet('core').setAttribute(
00252             '#character-attr-output', 'title', 'text & stuff')
00253         return self.render()

Definition at line 264 of file demoview.py.

00264 
00265     def protocolAttributeENDCDATA(self):
00266         self.getCommandSet('core').setAttribute(
00267             '#character-attr-output', 'title', 'before ]]> after')
00268         return self.render()
00269     

Definition at line 259 of file demoview.py.

00259 
00260     def protocolAttributeGT(self):
00261         self.getCommandSet('core').setAttribute(
00262             '#character-attr-output', 'title', 'text > stuff')
00263         return self.render()

Definition at line 254 of file demoview.py.

00254 
00255     def protocolAttributeLT(self):
00256         self.getCommandSet('core').setAttribute(
00257             '#character-attr-output', 'title', 'text < stuff')
00258         return self.render()

Definition at line 232 of file demoview.py.

00232 
00233     def protocolENDCDATA(self):
00234         self.getCommandSet('core').replaceInnerHTML(
00235             '#character-output', 'before ]]> after')
00236         return self.render()
00237 

Definition at line 227 of file demoview.py.

00227 
00228     def protocolGT(self):
00229         self.getCommandSet('core').replaceInnerHTML(
00230             '#character-output', 'text > stuff')
00231         return self.render()

Definition at line 243 of file demoview.py.

00243 
00244     def protocolLargeAttribute(self):
00245         classes = ' '.join(['h' + hex(i)[2:] * i for i in range(70)])
00246         self.getCommandSet('core').setAttribute(
00247             '#attribute-output', 'class', classes + ' largeattr')
00248         return self.render()

Definition at line 211 of file demoview.py.

00211 
00212     def protocolLargeDataset(self):
00213         text = 'really ' * 690
00214         self.getCommandSet('core').replaceInnerHTML(
00215             '#dataset-output', '<em>%s</em>' % (text + 'large text'))
00216         return self.render()

Definition at line 222 of file demoview.py.

00222 
00223     def protocolLT(self):
00224         self.getCommandSet('core').replaceInnerHTML(
00225             '#character-output', 'text < stuff')
00226         return self.render()

Definition at line 238 of file demoview.py.

00238 
00239     def protocolSmallAttribute(self):
00240         self.getCommandSet('core').setAttribute(
00241             '#attribute-output', 'class', 'some smallattr')
00242         return self.render()

Definition at line 206 of file demoview.py.

00206 
00207     def protocolSmallDataset(self):
00208         self.getCommandSet('core').replaceInnerHTML(
00209             '#dataset-output', '<em>Worked</em>')
00210         return self.render()

Definition at line 111 of file demoview.py.

00111 
00112     def removeNodeXpath(self):
00113         # XXX the xpath selector is now moved out of the core, see suppl, product "azaxslt"
00114         sel = self.getSelector('xpath', "//P[@id='xpath']/following-sibling::*[position()=1]")
00115         self.getCommandSet('core').deleteNode(sel)
00116         return self.render()
       

Definition at line 149 of file demoview.py.

00149 
00150     def reset(self):
00151         self.getCommandSet('effects').effect('.effects', 'appear')
00152         return self.render()

Here is the caller graph for this function:

Definition at line 88 of file demoview.py.

00088 
00089     def saveText(self, value):
00090         'Inserts the value to display it on the page'
00091         # We need to make unicode. But on Z2 we receive utf-8, on Z3 unicode
00092         value = force_unicode(value, 'utf')
00093         self.getCommandSet('core').replaceInnerHTML('div#text', value+'<input type="hidden" name="value" value="'+value+'" />')
00094         return self.render()
    
returns select content 

Definition at line 122 of file demoview.py.

00122 
00123     def updateSlaveSelector(self, masterid, value):
00124         """ returns select content """
00125         mapping = {}
00126         mapping['']=[]
00127         mapping['animals']=['dog', 'cat', 'cow']
00128         mapping['machines']=['computer', 'car', 'airplane']
00129         # calculate the slave id
00130         master, _dummy = masterid.split('-')
00131         slaveid = '%s-slave' % master
00132         # make the payload
00133         result = ['<select id="%s">' % slaveid]
00134         result.extend(['<option>%s</option>' % item for item in mapping[value]])
00135         result.append('</select>')
00136         # XXX See above remark why we need to replace the outer select.
00137         self.getCommandSet('core').replaceHTML('select#%s' % slaveid, ' '.join(result))
00138         return self.render()


The documentation for this class was generated from the following file: