Errata

Building the Realtime User Experience

Errata for Building the Realtime User Experience

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page 23
In the SQL request of the first block of PHP code

The "where" keyword is missing in the SQL request.

last_update > date_format(now() - interval {$since_age} second,
should read:
where last_update > date_format(now() - interval {$since_age} second,

fnor  Jul 15, 2010 
Printed Page 32
php code

The PHP code for index.php will send a subscription request for PubSubHubbub, but the callback from the hub will fail using the code from the book:

if($_REQUEST['request_subscription']) {

The hub callback does not include the 'request_subscription' parameter, and php issues an error message which won't let the callback succeed and verify the challenge. Change the PHP code to make it work to this:

if(isset($_REQUEST['request_subscription']) {

Since the isset() function will not fail, and the callback works.

rheotaxis  Sep 14, 2010 
Printed Page 82
starting tornado.web.Application in python code

The following corrected code allows the UpdateHandler to be called.

application = tornado.web.Application([
(r"/", MainHandler),
(r"/updates", UpdateHandler),
], static_path=local_static_path)

This seems to solve the problem reported for printed page 97.

rheotaxis  Sep 09, 2010 
Printed Page 89
sample code

I had to put the import statements inside the run methods of both the TweetFirehose and TweetProcessor thread classes. For instance:

def run(self):
import urllib2
import base64

Otherwise, Python could not find them. (Python 2.6 on Windows Vista)

rheotaxis  Sep 10, 2010 
PDF Page 89

http://stream.twitter.com/1/statuses/sample.json

is now deprecated, use

https://stream.twitter.com/1.1/statuses/sample.json

instead(version 1.1 with https)

Anonymous  May 24, 2013 
Printed Page 90
setting message["html"] in the python code

The python statement that sets the message["html"] is too long for the printed page and is not properly indented on the continuation lines below the start of the statement. After I combined the 4 printed lines into one single python statement, the problem was resolved.

message["html"] = "<div class=\"message\" id=\"m" +
message["id"] +
"\"><strong>" + t['user']['screen_name'] + ": </strong>" +
t['text'] + "</div>"

rheotaxis  Sep 09, 2010 
Printed Page 90
sample code, top of page

Add import statement for uuid in the TweetProcessor run method.

def run(self):
import uuid

rheotaxis  Sep 10, 2010 
Printed Page 91
after 4th paragraph

After adding the Python threads for pulling tweets from Twitter, the threads have to be started. The sample code does not show this, nor does the text describe it. I added it to the bottom of the runner.py file as shown here by the four lines in the middle of this code (from page 82.)

if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
tornado.options.parse_command_line()

myFirehose = TweetFirehose()
myProcessor = TweetProcessor()
myFirehose.start()
myProcessor.start()

http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

rheotaxis  Sep 10, 2010 
Printed Page 97
5th paragraphy

The last sentence says "the URL /updates...has been mapped in Tornado to the UpdateHandler method in runner.py." However, this does not seem to be the case. After starting the runner.py script on my server and visiting the page in Firefox with Firebug, the /updates is not found. I can see the POST being logged, but the UpdateHandler is not being called.

rheotaxis  Sep 09, 2010 
Printed Page 97
5th Paragraph, last sentence.

"The request is being made to the URL /updates, which has been mapped in Tornado to the UpdateHandler method in runner.py"

This was not mapped anywhere in the chapter prior to this statement.

Charlie Choiniere  Sep 16, 2010 
Printed Page 123
python code after comment #build and send the notification

the indentation of the python code should match the rest of the code in the def post(self) method of the TypingHandler class.

# build and send notification
data = dict(from_user_id=from_user_id, to_user_id=to_user_id)
msg = notification('typing', data)
self.chat.send_notification(msg, user_id=to_user_id)

rheotaxis  Sep 11, 2010 
PDF Page 124
First block of Javascript code

There should not be any ";" at the end of the last element in the object declaration.

previous_typing_ping: 0,
timeouts: {};
};

should read:

previous_typing_ping: 0,
timeouts: {}
};

fnor  Jul 23, 2010 
PDF Page 124
Last paragraph

we?ll immediately send an HTTP request to /send
should read:
we?ll immediately send an HTTP request to /typing

fnor  Jul 23, 2010 
PDF Page 145
Last paragraph of code

The is_authenticated method should be called on an instance of the IMUser class, not on the class itself

if not IMUser.is_authenticated(message.sender):
should read:
if not IMUser().is_authenticated(message.sender):

fnor  Jul 24, 2010 
Printed Page 145
python code definition of is_authenticated() method in the IMUser class

Running this sample code from the book in Google App Engine generated error message:

if not IMUser.is_authenticated(message.sender):
TypeError: unbound method is_authenticated() must be called with IMUser instance as first argument (got unicode instance instead)

One possible solution is to change the method definition to a static method like this:

@staticmethod
def is_authenticated(email):

rheotaxis  Sep 14, 2010 
Printed Page 145
Final code block (if not IMUser...)

When I attempt to run the authentication code I get the following error in my appengine log:

unbound method is_authenticated() must be called with IMUser instance as first argument (got unicode instance instead)

My code is verbatim from the book.

I was able to fix the "missing g error" already submitted on my own but can't figure this one out!

Jesse  Feb 14, 2011 
PDF Page 146
2nd paragraph of the "Introducing a Third Party" chapter

searching the archive of he New York Times
shouldr read:
searching the archive of the New York Times

fnor  Jul 24, 2010 
PDF Page 153
In the "The SMS Landscape" chapter

The most complete option wold be to connect
should read:
The most complete option would be to connect

fnor  Jul 24, 2010 
PDF Page 195
3rd line of code

This line is incorrect and throws an exception:
url = self.request.headers['Referer']

It should be:
url = self.request.headers.get('Referer')


robflaherty  Oct 12, 2010 
PDF Page 196
End of the code block

Page 204, the developper is asked to create a directory called static.

static_path=os.path.join(os.path.dirname(__file__), "static-new"),
should read:
static_path=os.path.join(os.path.dirname(__file__), "static"),

fnor  Jul 26, 2010 
PDF Page 199
End of the code block

if last_ping_in_seconds <(time.time() - Analytics.ping_timeout_time):
should read:
if last_ping_in_seconds < Analytics.ping_timeout_time:

fnor  Jul 26, 2010 
PDF Page 200
End of the first code block

logging.error("Error remove user: %s, %url: %s", uid, url)
Should read:
logging.error("Error remove user: %s, url: %s", uid, url)

fnor  Jul 26, 2010