Hi Nick

The meat is not in qooxdoo.js. Without knowing all too much of qooxdoo 
this demo took only a few hours to write. The source is there for the 
client side, JScript can be delivered on the fly when injecting widgets. 
Poke around with Firebug and you'll see the meat in the code islands 
named qooxdoo.qxcalculator, web.playground, ...

For projects at the complexity level you will arrive at very early in 
your project a PHP backend and 'whatever'RPC is simply not cutting to 
the meat in my opinion, because of a lot of missing concepts in PHP. 
Code in PHP becomes usually muddled really fast when solving that type 
of problem, that there are simply no solutions around that I know of. 
Usually it's resorting to Java or Python and if you want to go massively 
parallel then Python and stackless are doing its job nicely as you can 
see for instance with project EVE http://play.eveonline.com/en/home.aspx

So if you want to build RPC/Comet based apps in the browser I would 
suggest you scan the archives of http://cometdaily.com/
You will see that the resources are few in this particular area (and as 
an aside: WebSockets will not be any easier to handle, things stay 
highly asynchronous). If you still feel inclined to go with what I 
suggested I can point you in the right direction and help you along, 
though I do not have an 'industrial grade' solution framework, you can 
download.

Good luck, Werner

The server side coding of qxcalculator:

#! /usr/bin/env python
#-*- coding: iso-8859-1 -*-

"""
qxcalculator.py - a minimal Qooxdoo calculator

author     : Werner Thie, wth
last edit  : wth, 24.03.2010
modhistory :
   11.03.2010 - wth, created
"""

import sys, os

from twisted.internet import reactor
from twisted.python import log

from nevow import static, athena, loaders, inevow, url, tags as T, 
inevow, guard

from nevow.page import Element

from asite.common.helpers import uc

class qxCalculator(athena.LiveElement):
   jsClass = u'qooxdoo.qxcalculator.qxCalculator'

   docFactory = loaders.xmlstr("""
     <div name='qxcalculator' 
xmlns:nevow='http://nevow.com/ns/nevow/0.1' nevow:render='liveElement'>
     </div>
   """)

   def __init__(self, qooxdoopath, *a, **kw):
     super(qxCalculator, self).__init__(*a, **kw)
     self.qooxdoopath  = qooxdoopath
     self.result    = 0.0
     self.comma     = 0.0
     self.scratch   = 0.0
     self.operator  = ''
     self.opPending = False
     self.memory    = 0.0

   @athena.expose
   def keyPressed(self, key):
     if key == 'C':
       self.result  = 0.0
       self.comma   = 0.0
       self.scratch = 0.0
       self.opPending = False
     elif key in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
       if self.opPending:
         self.result = 0.0
         self.comma  = 0.0
         self.opPending = False
       if self.comma > 0.0:
         self.result = self.result + (float(key) / self.comma)
         self.comma = self.comma * 10.0
       else:
         self.result = (self.result * 10.0) + float(key)
     elif key == '.' and self.comma == 0.0:
       self.comma = 10.0
     elif key == 'MC':
       self.memory = 0.0
     elif key == 'MR':
       self.result = self.memory
     elif key == 'M+':
       self.memory += self.result
     elif key == 'M-':
       self.memory -= self.result
     elif key in ['+', '-', '*', '/', '=']:
       if self.scratch != 0.0:
         if self.operator == '+':
           self.result += self.scratch
         elif self.operator == '-':
           self.result = self.scratch - self.result
         elif self.operator == '*':
           self.result *= self.scratch
         elif self.operator == '/':
           self.result = self.scratch / self.result
         self.operator = ''
       self.opPending = True
       if key == '=':
         self.operator = ''
         self.scratch = 0.0
       else:
         self.operator = key
         self.scratch = self.result

     log.msg('---- key pressed: ', key)
     log.msg('result   : ', self.result)
     log.msg('scratch  : ', self.scratch)
     log.msg('comma    : ', self.comma)
     log.msg('operator : ', self.operator)
     log.msg('pending  : ', self.opPending)

     return self.result

   def detached(self):
     #clean up whatever needs cleaning...
     log.msg('qxCalculator Object was detached cleanly')



Nick Watkins wrote:
> Thanks for the suggestion. That project looks promising. I took a look at
> your example and it seems to replicate basically the functionality I'm
> looking for. Is there a source version you have available? The qooxdoo.js is
> a lot to muck through to find the "meat" of the example. The only thing I
> have reservations about is that my Python knowledge is fundamental at best.
> I was really hoping for something implemented with a PHP back-end through
> soemthing like JsonRPC.


------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to