Skip to Main Content
Google Wave: Up and Running
book

Google Wave: Up and Running

by Andres Ferrate
March 2010
Intermediate to advanced content levelIntermediate to advanced
304 pages
8h 23m
English
O'Reilly Media, Inc.
Content preview from Google Wave: Up and Running

Geo Bot

You can browse or check out the source code at http://code.google.com/p/geo-bot.

Code

from waveapi import events from waveapi import robot from waveapi import element from waveapi import ops from waveapi import appengine_robot_runner import urllib from google.appengine.api import urlfetch from xml.dom import minidom def OnRobotAdded(event, wavelet): """Invoked when the robot has been added.""" badge = 'http://geo-bot.appspot.com/images/geo-bot-badge.png' image = element.Image(url=badge, width=220, height=35) root_blip = wavelet.root_blip new_blip = root_blip.reply() new_blip.append(image) GeoProcess(root_blip) def OnBlipSubmitted(event, wavelet): """Invoked when a blip is sent to the wavelet. Gets new blip and passes blip to GeoProcess function""" blip = event.blip GeoProcess(blip) def GeoProcess(blip): """Send blip information to Yahoo! Placemaker via YQL query""" contents = blip.text.replace('"', ' ') utf_contents = contents.encode('utf-8') #Set up the form fields for the request to the YQL service form_fields = { 'q': 'SELECT * FROM geo.placemaker WHERE \ documentContent="' + utf_contents + '" AND documentType="text/plain"', 'format': 'xml' } #Encode the form data form_data = urllib.urlencode(form_fields) #Send the request to YQL API, with encoded form field data #If the request is successful, parse and update content in blip url = 'http://query.yahooapis.com/v1/public/yql' content_type = 'application/x-www-form-urlencoded' result = urlfetch.fetch(url = url, payload = form_data, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Google™ Search and Tools in a Snap

Google™ Search and Tools in a Snap

Preston Gralla
SUSE™ Linux 10 Unleashed

SUSE™ Linux 10 Unleashed

Michael McCallister

Publisher Resources

ISBN: 9781449378646Errata PagePurchase book