[KSS-checkins] r48731 - kukit/kss.core/trunk/kss/core/plugins/core/demo

jvloothuis at codespeak.net jvloothuis at codespeak.net
Fri Nov 16 21:24:21 CET 2007


Author: jvloothuis
Date: Fri Nov 16 21:24:19 2007
New Revision: 48731

Added:
   kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.kss
   kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt
Modified:
   kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml
   kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py
   kukit/kss.core/trunk/kss/core/plugins/core/demo/zopeconfig.py
Log:

Added tests for the protocol implementation.


Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml
==============================================================================
--- kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml	(original)
+++ kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml	Fri Nov 16 21:24:19 2007
@@ -432,5 +432,82 @@
     name="draganddrop.kss"
     />
 
+  <!-- protocol -->
+  <browser:page
+      for="kss.demo.interfaces.ISimpleContent"
+      template="protocol.pt"
+      name="client-server-protocol"
+      permission="zope.View"
+      />
+
+  <browser:resource
+    file="protocol.kss"
+    name="protocol.kss"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolSmallDataset"
+    name="protocolSmallDataset"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolLargeDataset"
+    name="protocolLargeDataset"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolSmallAttribute"
+    name="protocolSmallAttribute"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolLargeAttribute"
+    name="protocolLargeAttribute"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolAMP"
+    name="protocolAMP"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolLT"
+    name="protocolLT"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolGT"
+    name="protocolGT"
+    permission="zope.View"
+    />
+
+  <browser:page
+    for="kss.demo.interfaces.ISimpleContent"
+    class=".demoview.KSSDemoView"
+    attribute="protocolENDCDATA"
+    name="protocolENDCDATA"
+    permission="zope.View"
+    />
+
 </configure>
 

Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py	(original)
+++ kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py	Fri Nov 16 21:24:19 2007
@@ -198,3 +198,52 @@
         """html insert"""
         self.getCommandSet('core').insertHTMLAsLastChild('div#frame', '<div class="type2">KSS for a life. %s</div>' % (str(datetime.datetime.now()), ))
         return self.render()
+
+
+    # protocol
+    def protocolSmallDataset(self):
+        self.getCommandSet('core').replaceInnerHTML(
+            '#dataset-output', '<em>Worked</em>')
+        return self.render()
+
+    def protocolLargeDataset(self):
+        text = 'really ' * 690
+        self.getCommandSet('core').replaceInnerHTML(
+            '#dataset-output', '<em>%s</em>' % (text + 'large text'))
+        return self.render()
+
+    def protocolAMP(self):
+        self.getCommandSet('core').replaceInnerHTML(
+            '#character-output', 'text & stuff')
+        return self.render()
+
+    def protocolLT(self):
+        self.getCommandSet('core').replaceInnerHTML(
+            '#character-output', 'text < stuff')
+        return self.render()
+
+    def protocolGT(self):
+        self.getCommandSet('core').replaceInnerHTML(
+            '#character-output', 'text > stuff')
+        return self.render()
+
+    def protocolENDCDATA(self):
+        self.getCommandSet('core').replaceInnerHTML(
+            '#character-output', 'before ]]> after')
+        return self.render()
+
+
+    def protocolSmallAttribute(self):
+        self.getCommandSet('core').setAttribute(
+            '#attribute-output', 'class', 'some smallattr')
+        return self.render()
+
+    def protocolLargeAttribute(self):
+        classes = ' '.join(['h' + hex(i)[2:] * i for i in range(70)])
+        self.getCommandSet('core').setAttribute(
+            '#attribute-output', 'class', classes + ' largeattr')
+        return self.render()
+
+
+
+    

Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.kss
==============================================================================
--- (empty file)
+++ kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.kss	Fri Nov 16 21:24:19 2007
@@ -0,0 +1,39 @@
+#small-dataset:click {
+    evt-click-preventdefault: true;
+    action-server: protocolSmallDataset;
+}
+
+#large-dataset:click {
+    evt-click-preventdefault: true;
+    action-server: protocolLargeDataset;
+}
+
+#small-attribute:click {
+    evt-click-preventdefault: true;
+    action-server: protocolSmallAttribute;
+}
+
+#large-attribute:click {
+    evt-click-preventdefault: true;
+    action-server: protocolLargeAttribute;
+}
+
+#amp:click {
+    evt-click-preventdefault: true;
+    action-server: protocolAMP;
+}
+
+#lt:click {
+    evt-click-preventdefault: true;
+    action-server: protocolLT;
+}
+
+#gt:click {
+    evt-click-preventdefault: true;
+    action-server: protocolGT;
+}
+
+#endcdata:click {
+    evt-click-preventdefault: true;
+    action-server: protocolENDCDATA;
+}
\ No newline at end of file

Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt
==============================================================================
--- (empty file)
+++ kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt	Fri Nov 16 21:24:19 2007
@@ -0,0 +1,75 @@
+<html tal:define="viewname string:protocol">
+  <head>
+    <metal:header use-macro="context/@@header_macros/header_resources">
+      <metal:custom_resources fill-slot="custom_resources"> 
+        <style type="text/css">
+          .smallattr { color: yellow; }
+          .largeattr { color: green; }
+        </style>
+      </metal:custom_resources>
+    </metal:header>
+  </head>
+
+  <body>
+    
+    <p metal:use-macro="context/@@body_macros/header">header</p>
+
+    <h1>Client - Server Protocol</h1>
+    <p>
+      This demo exercises the communication between the client and the
+      server.
+    </p>
+
+    <h2>Data size of parameters</h2>
+    <p>Some browsers (Firefox in particular) had (or have) problems
+    with large text nodes in XML. The next examples show replacements
+    with large and small datasets.</p>
+
+    <ol>
+      <li><a href="#" id="small-dataset">Small dataset</a></li>
+      <li><a href="#" id="large-dataset">Large dataset</a></li>
+    </ol>
+
+    <p>Currently kss.core treats non-HTML commands differently from
+    others. The following examples show why I think this to be a
+    mistake.</p>
+
+    <ol>
+      <li><a href="#" id="small-attribute">Small attribute</a></li>
+      <li><a href="#" id="large-attribute">Large attribute</a></li>
+    </ol>
+    
+    <div id="attribute-output">
+      The parent node (div) will get an (in)sane amount of classes.
+    </div>
+
+    <h2>XML escaping</h2> 
+    <p>Since the response message is a XML document it should obey the
+    escaping rules of XML.</p>
+
+    <blockquote cite="http://www.w3.org/TR/REC-xml/#syntax">
+    The ampersand character (&amp;) and the left angle bracket (&lt;) MUST
+    NOT appear in their literal form, except when used as markup
+    delimiters, or within a comment, a processing instruction, or a
+    CDATA section. If they are needed elsewhere, they MUST be escaped
+    using either numeric character references or the strings "&amp;amp;"
+    and "&amp;lt;" respectively. The right angle bracket (>) may be
+    represented using the string "&amp;gt;", and MUST, for compatibility,
+    be escaped using either "&amp;gt;" or a character reference when it
+    appears in the string "]]&gt;" in content, when that string is not
+    marking the end of a CDATA section.
+    </blockquote>
+
+    <ol>
+      <li><a href="#" id="amp">Command with an &amp;</a></li>
+      <li><a href="#" id="lt">Command with a &lt;</a></li>
+      <li><a href="#" id="gt">Command with a &gt;</a></li>
+      <li><a href="#" id="endcdata">Command with ]]&gt; in a CDATA block</a></li>
+    </ol>
+
+    <div id="character-output">
+      test data will appear here
+    </div>
+    
+  </body>
+</html>

Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/zopeconfig.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/plugins/core/demo/zopeconfig.py	(original)
+++ kukit/kss.core/trunk/kss/core/plugins/core/demo/zopeconfig.py	Fri Nov 16 21:24:19 2007
@@ -31,6 +31,7 @@
         KSSDemo('', '', "error_handling.html", "Error handling"),
         KSSDemo('', '', "preventdefault.html", "Preventdefault (a.k.a. Safari workarounds)"),
         KSSDemo('', '', "html_inserts.html", "HTML insertions (Change tag content returns)"),
+        KSSDemo('', '', "client-server-protocol", "Client server protocol"),
 ##      KSSDemo('', '',  "draganddrop.html", "Scriptaculous drag and drop"),
         KSSDemo('', 'Parameter functions', 'pf_forms.html', 'Forms'),
         KSSDemo('', 'Selectors', 'selectors.html', 'Parent node selector'),


More information about the Kukit-checkins mailing list