Rough and dirty - but works for capabilities.xml already. It's odd that google's start_response returns a write method - at least it's not what the wsgi tutorials do - and does not return anything from the app (env, start_response) call. Oh well.
--- # coding: utf8 import sys import cStringIO path = 'applications/%s/modules' % request.application if not path in sys.path: sys.path.append(path) from google.appengine.ext import webapp from waveapi import events from waveapi import model from waveapi import robot def OnParticipantsChanged(properties, context): """Invoked when any participants have been added/removed.""" added = properties['participantsAdded'] for p in added: Notify(context) def OnRobotAdded(properties, context): """Invoked when the robot has been added.""" root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText("I'm alive!") def Notify(context): root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText("Hi everybody!") # Web2py function def process(): def normalize(x): if x.startswith('wsgi'): return x.replace('_', '.', 1) else: return x.upper() buffer = cStringIO.StringIO() def start_response(status, headers, exc_info=None): status_code, status_txt = status.split(' ',1) if status_txt == 'OK': for k,v in headers: response.headers[k] = v else: raise HTTP(status_code) return buffer.write wsgienv = dict() for k, v in request.env.items(): wsgienv[normalize(k)] = v myRobot = robot.Robot('wavedirectory', image_url='http://wavedirectory.appspot.com/icon.png', version='1', profile_url='http://wavedirectory.appspot.com/') myRobot.RegisterHandler(events.WAVELET_PARTICIPANTS_CHANGED, OnParticipantsChanged) myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded) app = webapp.WSGIApplication([ ('/init/robot/process/capabilities.xml', lambda: robot.RobotCapabilitiesHandler(myRobot)), ('/_wave/robot/profile', lambda: robot.RobotProfileHandler (myRobot)), ('/_wave/robot/jsonrpc', lambda: robot.RobotEventHandler (myRobot)), ], debug=False) app(wsgienv, start_response) buffer.seek(0) return buffer.read() On Oct 28, 5:13 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > I would do the same, the problem is the original environment is not > passed to the function there should be a hook for that. Something > like: > > request._wsgi_environ > > Massimo > > On Oct 28, 9:42 am, hcvst <hcv...@googlemail.com> wrote: > > > Hi Massimo, > > > I am trying to write a Google wave bot and use the wavebot client api > > as directly as possible as the internals are likely to change. > > Bots are just wsgi apps. > > > I've changed routes_in to map all calls originating from wave to > > one controller function. > > > Perhaps I should just emulate env and start_response: > > env would equal more or less request.env (all Caps and '_' replaced > > with '-' ) > > and start_response would be a simple callback to set response headers > > (and to > > raise an HTTP x if not OK 200). > > > How would you go about this? > > > Thanks, > > HC > > > On Oct 28, 4:06 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > On Oct 28, 7:05 am, hcvst <hcv...@googlemail.com> wrote: > > > > > Hi, > > > > > can I dispatch from a w2p controller to another wsgi app? Sth like: > > > > > def index(): > > > > wsgiapp(env, start_response) > > > > No > > > > > Alternatively, is there a method to write the HTTP response directly, > > > > where 'directly' could mean directly to the socket itself? > > > > No but the above approach would not allow that ether bacuse > > > start_response writes the headers anyway. Tell'us what you are trying > > > to accomplish because I am sure there is a way. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---