Errata


Print Print Icon

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question



Version Location Description Submitted By Corrected
Printed Page 16
2nd sentence

"When the action is competed, ..."
should be:
"When the action is completed, ..."
^

Anonymous 
Printed Page 17
2nd code snippet, 2nd line

"Connection to port 80."
should be:
"Connected to port 80."

Anonymous 
Printed Page 18
Example 2.5. portscan.py

"from connectiontester import testConnect"

should be

"from connectiontest import testConnect"

Anonymous 
Printed Page 18
Example 2-5

The testConnect function is imported from the previous example. The
import statement uses "connectiontester" as the module name but the
previous example uses connectiontest.py as the file name.

Anonymous 
Printed Page 22
bottom

"How does that work?" is included in the code block, not as a section heading.

Anonymous 
Printed Page 22
Example 2.7

The code printed in the book is out of date. The code in the current example code zip already fixes this problem.
The new code is listed below:
from twisted.internet import reactor, protocol
from twisted.protocols import basic

class EchoProtocol(basic.LineReceiver):

def connectionMade(self):
print "Connection from", self.transport.getPeer().host

def lineReceived(self, line):
if line == 'quit':
self.sendLine("Goodbye.")
self.transport.loseConnection()
else:
self.sendLine("You said: " + line)

class EchoServerFactory(protocol.ServerFactory):
protocol = EchoProtocol

if __name__ == "__main__":
port = 5001
reactor.listenTCP(port, EchoServerFactory())
print "Server running, press ctrl-C to stop."
reactor.run()

Anonymous 
Printed Page 23
at least on line 2

Page 23, at least on line 2: typo LineReciever should be LineReceiver.

Anonymous 
Printed Page 27
1st paragraph, 2nd sentence

SHould read:
"This means that when the result of client.downloadPage comes in, the
reactor will call returnFilename with the result of client.downloadPage
as the first argument and the filename as the second argument."

Anonymous 
Printed Page 35
Example 3-6 : function pagePart(), wrong indentation

Lines 17-20 of Example 3-6 should be indented like this:

else:
percent = '%dK' % (self.currentLength/1000)
print "33[1FProgress: " + percent
return client.HTTPDownloader.pagePart(self, data)

Anonymous 
Printed Page 43
the html in the renderHomePage code reads -

<title>Form Test</html>
when it should read -
<title>Form Test</title>

Anonymous 
Printed Page 43
First paragraph, second sentence

The text reads, "MyRequestHandler uses SetHeader to set the Content-Type header to text/html"... However, this call to SetHeader
doesn't appear anywhere in the example code on page 41!

This paragraph should read:
The Request class also provides a setHeader method for adding headers to
the response. For example, you can use setHeader to add a Content-Type
header indicating the type of content in the response body.
setHeader('Content-Type', 'text/plain') would generate the HTTP header
Content-Type: text/plain, telling the browser that the response is plain
text. If you don't manually set a Content-Type header, the Request class
will default to sending the Content-Type for HTML documents, text/html
(as it does when you run Example 4-2).

Anonymous 
Printed Page 47
Under "How Do I Do That?"

There is a sentence that reads:
The twisted.web.resource, twisted.web.static, and twisted.web.server
modules provide classes for working with requests at a higher level
than twisted.web.http.Resource, ..."
There's no such thing as twisted.web.http.Resource; I'm guessing that
twisted.web.http.Request was intended.

This is correct, it should read "at a higher level than
twisted.web.http.Request".

Anonymous 
Printed Page 48
Example 4-4. Resourcetree.py has been updated in the downloadable example code on our website.

Here is the updated code to replace the example in the book:

from twisted.web import resource, static, server

class ColorPage(resource.Resource):
def __init__(self, color):
self.color = color

def render(self, request):
return """
<html>
<head>
<title>Color: %s</title>
<DEFANGED_link type='text/css' href='/css/styles.css' rel='Stylesheet' />
</head>
<body DEFANGED_STYLE='background-color: #%s'>
<h1>This is #%s.</h1>
<p DEFANGED_STYLE='background-color: white'>
<a href='/colors/'>Back</a>
</p>
</body>
</html>
""" % (self.color, self.color, self.color)

class ColorRoot(resource.Resource):
def __init__(self):
resource.Resource.__init__(self)
self.requestedColors = []
self.putChild('', ColorIndexPage(self.requestedColors))

def render(self, request):
# redirect /colors -> /colors/
request.redirect(request.path + '/')
return "Please use /colors/ instead."

def getChild(self, path, request):
if path not in self.requestedColors:
self.requestedColors.append(path)
return ColorPage(path)

class ColorIndexPage(resource.Resource):
def __init__(self, requestedColorsList):
resource.Resource.__init__(self)
self.requestedColors = requestedColorsList

def render(self, request):
request.write("""
<html>
<head>
<title>Colors</title>
<DEFANGED_link type='text/css' href='/css/styles.css' rel='Stylesheet' />
</head>
<body>
<h1>Colors</h1>
To see a color, enter a url like
<a href='ff0000'>/colors/ff0000</a>. <br />
Colors viewed so far:
<ul>""")
for color in self.requestedColors:
request.write(
"<li><a href='%s' DEFANGED_STYLE='color: #%s'>%s</a></li>" % (
color, color, color))
request.write("""
</ul>
</body>
</html>
""")
return ""

class HomePage(resource.Resource):
def render(self, request):
return """
<html>
<head>
<title>Colors</title>
<DEFANGED_link type='text/css' href='/css/styles.css' rel='Stylesheet' />
</head>
<body>
<h1>Colors Demo</h1>
What's here:
<ul>
<li><a href='/colors'>Color viewer</a></li>
</ul>
</body>
</html>
"""

if __name__ == "__main__":
from twisted.internet import reactor
root = resource.Resource()
root.putChild('', HomePage())
root.putChild('colors', ColorRoot())
styles = resource.Resource()
styles.putChild('styles.css', static.File('styles.css'))
root.putChild('css', styles)
site = server.Site(root)
reactor.listenTCP(8000, site)
reactor.run()

Anonymous 
Printed Page 52
2nd paragraph, last sentence

"See Example 4-5 for an example of this technique"

change "Example 4-5" to "Example 4-6"

Anonymous 
Printed Page 68
IndexPage's render method

In example 5-1, the opening "<body>" tag in IndexPage's render method should probably
come before the "<a href='/Home'>Home</a>" line in order to have the example's output
come out correctly when viewed in a browser.
This is correct. <body> should come right after the line:

<head><title>Wiki Index</title></head>

Anonymous 
Printed Page 68
IndexPage's render method

IndexPage's render method is missing a closing "</html>" tag in the markup that it
will emit.

Anonymous 
Printed Page 70
3rd and 4th paragraphs

The text refers to a "PageSaverResource" class in the example code, however no such
class is defined in the example code. "PageSaverResource" should instead be
"SavePage".

Anonymous 
Printed Page 75
Example 5-3 code listing

siteRoot = rest_wiki.RootResource(wikiData)

Should read:
siteRoot = wiki.RootResource(wikiData)

There's no rest_wiki.py from the previous example -- just wiki.py. The example as
written will result in a NameError exception.

Anonymous 
Printed Page 80
Example 5.5 import statement

Example 5-5 soap_server.py has an import statement for rest_wiki. However,
there is no such example code - and I think the RootResource being
imported is supposed to be the one in wiki.py.
This is correct, the first line should just read:

import wiki

Anonymous 
Printed Page 81
4th paragraph (under "Calling SOAP Web Services")

The text:
"contains a soap client"
Should read:
"contains a SOAP client"

Anonymous 
Printed Page 83
Label for example 5-7

In my first edition, example 5-7 is labeled as 'pb_wiki.py'
on pages 83 and 84.

After the first line on page 84, I do not see any
more mention of pb_wiki.py, but instead pb_server.py is
discussed. All references within the section should be
pb_server.py.

Anonymous 
Printed Page 84
In definition of remote_getReporter

This method should return a WikiReporter instance, not a RemoteWikiReporter instance

Anonymous 
Printed Page 84
In definition of WikiReporter class

The method name listNeededPages is not allowed to be accessed remotely as it doesn't
conform to the remote_methodName requirement of Perspective Broker. Trying to run
the test client script from example 5-8 results in an error. This line:

def listNeededPages(self):

should instead read:

def remote_listNeededPages(self):

Anonymous 
Printed Page 96
SQL code block

lastname varchar(100),

should read:
lastname varchar(100)

As printed, the example SQL will result in a syntax error and won't work.

Anonymous 
Printed Page 128
"... a tuple with the hostname used in by the client ..."

should be
"... a tuple with the hostname used by the client ..."

Anonymous 


"Review [Twisted's] strengths with this bible of advice in hand."
--Diane Donovan, Library Bookwatch