Author: jmorliaguet
Date: Wed Feb 15 09:39:57 2006
New Revision: 2382

Added:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/__init__.py
   (contents, props changed)
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/browser.py
   (contents, props changed)
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/configure.zcml
   (contents, props changed)
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/cpsskins_latency.pt
   (contents, props changed)
Modified:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml
Log:

- saving work:

  added tests to eliminate storage latency when saving data on a remote server
  with two types of sequences: queue and stack (not implemented yet).



Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml
       (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml
       Wed Feb 15 09:39:57 2006
@@ -10,4 +10,6 @@
 
   <include package=".forms" />
 
+  <include package=".latency" />
+
 </configure>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/__init__.py
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/__init__.py
  Wed Feb 15 09:39:57 2006
@@ -0,0 +1 @@
+#

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/browser.py
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/browser.py
   Wed Feb 15 09:39:57 2006
@@ -0,0 +1,25 @@
+
+import random
+import time
+
+from zope.app.publisher.browser import BrowserView
+from zope.app.cache.ram import RAMCache
+
+from cpsskins import minjson as json
+
+cache = RAMCache()
+
+class Views(BrowserView):
+
+    def setDataWithLatency(self, data):
+        data = json.read(data)
+
+        # this only simulates latency on the server.
+        # network latency can be simulated with the AJAX Proxy tool
+        # (https://sourceforge.net/projects/jpspan/)
+        time.sleep(random.randint(1, 4))
+
+        storage = data['storage']
+        cache.set(data, storage, {})
+        return json.write(data)
+

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/configure.zcml
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/configure.zcml
       Wed Feb 15 09:39:57 2006
@@ -0,0 +1,25 @@
+<configure
+    xmlns:browser="http://namespaces.zope.org/browser";>
+
+  <browser:page
+      for="*"
+      layer="cpsskins-test"
+      name="cpsskins_latency.html"
+      permission="zope.Public"
+      template="cpsskins_latency.pt"
+  />
+
+  <browser:pages
+      layer="cpsskins-test"
+      for="*"
+      class=".browser.Views"
+      permission="zope.Public">
+
+    <browser:page
+        name="setDataWithLatency.html"
+        attribute="setDataWithLatency"
+    />
+
+  </browser:pages>
+
+</configure>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/cpsskins_latency.pt
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/cpsskins_latency.pt
  Wed Feb 15 09:39:57 2006
@@ -0,0 +1,184 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xml:lang="en" lang="en"
+      xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+  <title>CPSSkins Unit test file</title>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+  <script src="/++skin++cpsskins/@@/++resource++prototype.js"
+          type="text/javascript"></script>
+  <script src="/++skin++cpsskins/@@/++resource++json.js"
+          type="text/javascript"></script>
+  <script src="/++skin++cpsskins/@@/++resource++ctal.js"
+          type="text/javascript"></script>
+  <script src="/++skin++cpsskins/@@/++resource++cpsskins.js"
+          type="text/javascript"></script>
+  <link rel="stylesheet" type="text/css"
+        href="/++skin++cpsskins/@@/++resource++cpsskins.css" />
+
+  <style type="text/css">
+  .bar {
+    color: #fff;
+    margin: 2px;
+    padding: 2px;
+    font: 12px arial, sans-serif;
+    border: 1px solid #003;
+    background-color: rgb(1, 2, 100);
+  }
+  table.results {
+    width: 100%;
+  }
+  table.results th {
+    background-color: #eee;
+    border: 1px solid #999;
+  }
+  table.results td {
+    width: 33%;
+    border: 1px solid #ccc;
+  }
+  </style>
+
+  <script type="text/javascript">
+    var model;
+
+    Event.observe(window, "load", init);
+
+    function init() {
+      run('no-sequence', 1);
+      run('stack-sequence', 2);
+      run('queue-sequence', 3);
+    }
+
+    function run(model_id, storage) {
+      var model = CPSSkins.getModelById(model_id);
+      $R(1,20).each(function(v) {
+        model.setData({'storage': storage, 'position': v});
+      });
+    }
+
+    Object.extend(Widgets, {
+
+      counter: function(def) {
+        var widget = Canvas.createNode({
+          tag: "div",
+          classes: "counter"
+        });
+        return new Counter(widget, def);
+      },
+    });
+
+    Counter = Class.create();
+    Counter.prototype = Object.extend(new CPSSkins.View(), {
+
+      render: function(data) {
+        var size = data.position * 10;
+        var div = Canvas.createNode(
+          {tag: "div", classes: "bar",
+           style: {width: size + "px",
+                   backgroundColor: "rgb(" + size + ",0,150)"},
+           text: " " + data.position + " "}
+        );
+        this.widget.appendChild(div);
+      }
+
+    });
+
+  </script>
+
+</head>
+<body>
+
+  <h1>CPSSkins: network latency</h1>
+
+  <!-- models -->
+  <ins class="model">
+  {"id": "no-sequence",
+   "data": {
+     "position": 0
+   },
+   "storage": {
+     "type": "remote",
+     "accessors": {
+       "set": "@@setDataWithLatency.html"
+     }
+  }}
+  </ins>
+
+  <ins class="model">
+  {"id": "stack-sequence",
+   "data": {
+     "position": 0
+   },
+   "storage": {
+     "type": "remote",
+     "access": {
+       "type": "stack"
+     },
+     "accessors": {
+       "set": "@@setDataWithLatency.html"
+     }
+  }}
+  </ins>
+
+  <ins class="model">
+  {"id": "queue-sequence",
+   "data": {
+     "position": 0
+   },
+   "storage": {
+     "type": "remote",
+     "access": {
+       "type": "queue"
+     },
+     "accessors": {
+       "set": "@@setDataWithLatency.html"
+     }
+  }}
+  </ins>
+
+  <table class="results">
+    <tr>
+
+      <th>No sequence</th>
+      <th>Queue sequence</th>
+      <th>Stack sequence</th>
+
+    </tr>
+
+    <tr>
+
+      <td valign="top">
+        <ins class="view">
+        {"widget": {
+           "type": "counter"
+          },
+         "model": "no-sequence"
+        }
+        </ins>
+      </td>
+
+      <td valign="top">
+        <ins class="view">
+        {"widget": {
+           "type": "counter"
+          },
+         "model": "stack-sequence"
+        }
+        </ins>
+      </td>
+
+      <td valign="top">
+        <ins class="view">
+        {"widget": {
+           "type": "counter"
+          },
+         "model": "queue-sequence"
+        }
+        </ins>
+      </td>
+
+    </tr>
+  </table>
+
+</body>
+</html>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to