Nice Robin,
why split it over two apps (init and _ah)?
On Sep 26, 6:17 pm, Robin B <[email protected]> wrote:
> how about something like this:
>
> To send:
> applications/init/controllers/default.py:
>
> def send():
> from google.appengine.api import xmpp
> user_address = '[email protected]'
> xmpp.send_invite(user_address)
> msg = "Someone has sent you a gift on Example.com. To
> view:http://example.com/gifts/"
> status_code = xmpp.send_message(user_address, msg)
> return dict(status_code=status_code)
>
> To receive:
> applications/_ah/controllers/xmpp.py:
>
> def message():
> if request.args[0] == 'chat' and request.method == 'POST':
> import logging
> message = request.vars
> logging.debug(str(message))
> return message
>
> Add this to app.yaml:
>
> inbound_services:
> - xmpp_message
>
> Check your logs to see incoming XMPP messages, only works on GAE
> production servers.
>
> Robin
>
> On Sep 26, 5:47 pm, murray3 <[email protected]> wrote:
>
> > Any chance of a basic skeleton app for this to get us started?
> > chrism
>
> > On Sep 24, 5:44 am, Robin B <[email protected]> wrote:
>
> > > If you port it to web2py, then you don't need to wrap their handler,
> > > unless I am misunderstanding.
>
> > > All that has to built a web2py controller function that can receive
> > > POST requests at:
>
> > > /_ah/xmpp/message/chat/
>
> > > The POST data is this:
> > > * from, the address of the sender of the message
> > > * to, the address of the recipient as described by the sender (see
> > > below)
> > > * body, the body of the message
> > > * stanza, the full XMPP message in its original XML form
>
> > > The IMProperty does not need to used, and it can just be a string.
>
> > > Once XMPP is enabled, Google will POST messages to web2py at /_ah/xmpp/
> > > message/chat/.
>
> > > Google's xmpp_handlers.CommandHandler is not needed for web2py, but
> > > some of the XML parser could be reused.
>
> > > Robin
>
> > > On Sep 23, 4:11 pm, mdipierro <[email protected]> wrote:
>
> > > > I agree. Most of what the rest of the code does should be easy to port
> > > > to web2py. But I need to understand how to wrap the handler so that I
> > > > can be called from a controller function. We could make a wsgi_adaptor
> > > > inside the controller but there has to be a better way.
>
> > > > On Sep 23, 3:57 pm, Robin B <[email protected]> wrote:
>
> > > > > Yes,
>
> > > > > I believe the url ('/_ah/xmpp/message/chat/') is significant
>
> > > > > what about:
>
> > > > > app='_ah'
> > > > > controller='xmpp'
> > > > > action='message'
>
> > > > > then handle the rest as args and call other controller functions?
>
> > > > > Robin
>
> > > > > On Sep 23, 2:57 pm, mdipierro <[email protected]> wrote:
>
> > > > > > Then it should be possible to rewrite the entire example as a web2py
> > > > > > application. Is there specific significance it the URL names ('/_ah/
> > > > > > xmpp/message/chat/') used in the example? Because preserving those
> > > > > > would require roots.
>
> > > > > > Massimo
>
> > > > > > On Sep 23, 2:25 pm, Robin B <[email protected]> wrote:
>
> > > > > > > looks like a string property that validates as an instant
> > > > > > > messaging
> > > > > > > handle.
>
> > > > > > >http://ru.ly/Nb
>
> > > > > > > class IM(object):
> > > > > > > """An instant messaging handle. Includes both an address and its
> > > > > > > protocol.
> > > > > > > The protocol value is either a standard IM scheme or a URL
> > > > > > > identifying the
> > > > > > > IM network for the protocol. Possible values include:
>
> > > > > > > Value Description
> > > > > > > sip SIP/SIMPLE
> > > > > > > unknown Unknown or unspecified
> > > > > > > xmpp XMPP/Jabber
> > > > > > > http://aim.com/ AIM
> > > > > > > http://icq.com/ ICQ
> > > > > > > http://talk.google.com/ Google Talk
> > > > > > > http://messenger.msn.com/ MSN Messenger
> > > > > > > http://messenger.yahoo.com/ Yahoo Messenger
> > > > > > > http://sametime.com/ Lotus Sametime
> > > > > > > http://gadu-gadu.pl/ Gadu-Gadu
>
> > > > > > > This is the gd:im element. In XML output, the address and
> > > > > > > protocol
> > > > > > > are
> > > > > > > provided as the address and protocol attributes, respectively.
> > > > > > > See:
> > > > > > > http://code.google.com/apis/gdata/common-elements.html#gdIm
>
> > > > > > > Serializes to '<protocol> <address>'. Raises BadValueError if
> > > > > > > tag is
> > > > > > > not a
> > > > > > > standard IM scheme or a URL.
> > > > > > > """
>
> > > > > > > Robin
>
> > > > > > > On Sep 23, 8:01 am, mdipierro <[email protected]> wrote:
>
> > > > > > > > What's a IM field?
>
> > > > > > > > On Sep 22, 10:13 pm, Robin B <[email protected]> wrote:
>
> > > > > > > > > You can edit app.yaml to dispatch requests to those xmpp
> > > > > > > > > handlers
> > > > > > > > > based on prefix (/_ah/*), and let web2py handle everything
> > > > > > > > > that's left
> > > > > > > > > (/*)
>
> > > > > > > > > Or you can rewrite those handlers as web2py
> > > > > > > > > controller/functions and
> > > > > > > > > use routes.py to map the specific urls to
> > > > > > > > > app/controller/function
>
> > > > > > > > > Robin
>
> > > > > > > > > On Sep 22, 5:44 pm, murray3 <[email protected]> wrote:
>
> > > > > > > > > > I am interested in the way we can convert GAE sample web
> > > > > > > > > > apps to
> > > > > > > > > > web2py, in particular the xmpp tutorial
> > > > > > > > > > :http://code.google.com/appengine/articles/using_xmpp.html
>
> > > > > > > > > > Seems straight forward to import the modules etc.
>
> > > > > > > > > > How should the following be ported to web2py to handle the
> > > > > > > > > > xmpp stuff?
> > > > > > > > > > def main():
> > > > > > > > > > app = webapp.WSGIApplication([
> > > > > > > > > > ('/', LatestHandler),
> > > > > > > > > > ('/_ah/xmpp/message/chat/', XmppHandler),
> > > > > > > > > > ], debug=True)
> > > > > > > > > > wsgiref.handlers.CGIHandler().run(app)
>
> > > > > > > > > > the tutorial states the following:
>
> > > > > > > > > > " There's one last thing we need to do to get this all
> > > > > > > > > > working, of
> > > > > > > > > > course - hook it up to the serving infrastructure so it can
> > > > > > > > > > serve
> > > > > > > > > > requests. Fortunately, a CommandHandler is a standard webapp
> > > > > > > > > > RequestHandler subclass, so we can set it up as we would
> > > > > > > > > > any other
> > > > > > > > > > handler. Modify the lines where the application variable is
> > > > > > > > > > defined to
> > > > > > > > > > read like this:
>
> > > > > > > > > > application = webapp.WSGIApplication([
> > > > > > > > > > ('/_ah/xmpp/message/chat/', XmppHandler)], debug=True)
>
> > > > > > > > > > The URL path here - /_ah/xmpp/message/chat - is a
> > > > > > > > > > 'reserved' one that
> > > > > > > > > > all XMPP messages get sent to. "
>
> > > > > > > > > > any pointers to get me started.
> > > > > > > > > > regards
> > > > > > > > > > chrism
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---