Author: jmorliaguet
Date: Sun Feb  5 22:54:00 2006
New Revision: 2303

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

- example of a simple aggregator.



Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/__init__.py
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/__init__.py
       Sun Feb  5 22:54:00 2006
@@ -0,0 +1 @@
+#

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/browser.py
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/browser.py
        Sun Feb  5 22:54:00 2006
@@ -0,0 +1,52 @@
+
+import time
+
+from zope.app.publisher.browser import BrowserView
+
+from cpsskins import minjson as json
+
+feeds_model_def = """{
+    "id": "feed%(id)s",
+    "data": {
+        "%(id)s": {"text": ""}
+     },
+     "storage": {
+         "type": "remote",
+         "accessors": {
+             "get": "@@getFeed?id=%(id)s"
+         }
+    }
+}
+"""
+
+feeds_data = {
+    '1': "May you live every day of your life. Jonathan Swift",
+    '2': "Only two things are infinite, the universe and human stupidity, "
+         "and I'm not sure about the former. Albert Einstein",
+    '3': "Nothing endures but change. Heraclitus (540 BC - 480 BC)",
+    '4': "Why are our days numbered and not, say, lettered? Woody Allen",
+    '5': "Some painters transform the sun into a yellow spot, others transform 
"
+         "a yellow spot into the sun. Pablo Picasso",
+    '6': "Fashion is a form of ugliness so intolerable that we have to alter "
+         "it every six months. Oscar Wilde",
+}
+
+class Views(BrowserView):
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def citeFeed(self, id=1):
+        return feeds_model_def % {'id': id}
+
+    def getFeed(self, id=1):
+        time.sleep(1)
+
+        data = {id: {
+            'text': feeds_data[id],
+            'updated': time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())
+            }
+        }
+        return json.write(data)
+

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/configure.zcml
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/configure.zcml
    Sun Feb  5 22:54:00 2006
@@ -0,0 +1,30 @@
+<configure
+    xmlns:browser="http://namespaces.zope.org/browser";>
+
+  <browser:page
+      for="*"
+      layer="cpsskins"
+      name="cpsskins_aggregator.html"
+      permission="zope.Public"
+      template="cpsskins_aggregator.pt"
+  />
+
+  <browser:pages
+      layer="cpsskins"
+      for="*"
+      class=".browser.Views"
+      permission="zope.Public">
+
+    <browser:page
+        name="citeFeed"
+        attribute="citeFeed"
+    />
+
+    <browser:page
+        name="getFeed"
+        attribute="getFeed"
+    />
+
+  </browser:pages>
+
+</configure>

Added: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/cpsskins_aggregator.pt
==============================================================================
--- (empty file)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/aggregator/cpsskins_aggregator.pt
    Sun Feb  5 22:54:00 2006
@@ -0,0 +1,105 @@
+<!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++cpsskins.js"
+          type="text/javascript"></script>
+  <link rel="stylesheet" type="text/css"
+        href="/++skin++cpsskins/@@/++resource++cpsskins.css" />
+
+  <style type="text/css">
+  .feedbox {
+    border: 1px solid red;
+    padding: 1em;
+    margin: 0.4em;
+    background-color: #fdc;
+  }
+
+  </style>
+
+  <script type="text/javascript">
+
+    Object.extend(Widgets, {
+
+      feedbox: function(def) {
+        var widget = Canvas.createNode({
+          tag: "div",
+          classes: "feeds"
+        });
+
+        return new FeedBox(widget, def);
+      }
+
+    });
+
+    FeedBox = Class.create();
+    FeedBox.prototype = Object.extend(new CPSSkins.View(), {
+
+      render: function(data) {
+        var widget = this.widget;
+        widget.innerHTML = '';
+
+        $R(1, 6).each(function(feed) {
+          var info = data[feed];
+          widget.appendChild(
+            Canvas.createNode({
+              tag: "div",
+              classes: "feedbox",
+              text: feed + ": " + info.text +
+                    " [updated: " + info.updated + "]"
+          }));
+        });
+
+      },
+
+    });
+
+  </script>
+
+</head>
+<body>
+
+  <h1>CPSSkins: feed aggregator</h1>
+
+  <div id="area0">
+
+    <ins class="model"
+         tal:repeat="id python: range(1, 7)"
+         tal:attributes="cite string:@@citeFeed?id=$id">
+    </ins>
+
+    <ins class="model">
+    {"id": "aggregator",
+     "data": {
+       "1": {},
+       "2": {},
+       "3": {},
+       "4": {},
+       "5": {},
+       "6": {}
+     },
+     "storage": {
+       "type": "compound",
+       "partitions": ["feed1", "feed2", "feed3", "feed4", "feed5", "feed6"]
+    }}
+    </ins>
+
+    <ins class="view">
+    {"widget": {
+      "type": "feedbox"
+     },
+     "model": "aggregator"
+    }
+    </ins>
+
+  </div>
+
+</body>
+</html>

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
       Sun Feb  5 22:54:00 2006
@@ -4,4 +4,6 @@
 
   <include package=".chat" />
 
+  <include package=".aggregator" />
+
 </configure>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to