Author: jmorliaguet
Date: Sat Feb  4 19:08:48 2006
New Revision: 2292

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/browser.py
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/cpsskins_chat.pt
Log:

- chat example: we store messages in a RAM cache on the server and display
  the remote host IP information.



Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/browser.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/browser.py      
(original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/browser.py      
Sat Feb  4 19:08:48 2006
@@ -2,12 +2,15 @@
 import time
 
 from zope.app.publisher.browser import BrowserView
+from zope.app.cache.ram import RAMCache
 from zope.app.session.interfaces import ISession
 
 from cpsskins import minjson as json
 
 RIGHT_ANSWERS = ('blue', 'red', 'yellow')
 
+cache = RAMCache()
+
 class Accessors(BrowserView):
 
     def __init__(self, context, request):
@@ -49,18 +52,19 @@
         return json.write(data)
 
     def getData2(self):
-        data = self.session.get('data2', {})
+        data = cache.query('data2', {}, {})
         return json.write(data)
 
     def setData2(self, data):
         data = json.read(data)
 
-        current_data = self.session.get('data2', {})
+        current_data = cache.query('data2', {}, {})
         messages = current_data.get('messages', [])
-        messages.append({'message': data['message']});
+        ip = self.request.get('REMOTE_ADDR')
+        messages.append({'message': data['message'], 'ip': ip});
 
         data['messages'] = messages
-        self.session['data2'] = data
+        cache.set(data, 'data2', {})
 
         return json.write(data)
 

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/cpsskins_chat.pt
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/cpsskins_chat.pt
     (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/cpsskins_chat.pt
     Sat Feb  4 19:08:48 2006
@@ -78,7 +78,7 @@
             Canvas.createNode({
               tag: "div",
               classes: "message",
-              text: m.message
+              text: '[' + m.ip + '] ' + m.message
           }));
 
         });
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to