@@ -152,9 +152,9 @@ it supports standard file read operations:
152152.. code-block :: python
153153
154154 >> > html = page.read()
155- >> > len (page )
155+ >> > len (html )
156156 373447
157- >> > print page
157+ >> > print html
158158
159159 < ! DOCTYPE html PUBLIC
160160 " -//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -182,7 +182,7 @@ Brief Interlude
182182
183183.. class :: big-centered
184184
185- "Some people, when confronted with a problem, think 'I know, I'ʹll use regular
185+ "Some people, when confronted with a problem, think 'I know, I'll use regular
186186expressions.' Now they have two problems."
187187
188188Even Better
@@ -265,9 +265,9 @@ Creating a new virtualenv is very very simple::
265265<ENV> is just the name of the environment you want to create. It's arbitrary.
266266Let's make one for our BeautifulSoup install::
267267
268- $ python virtualanv .py --distribute soupenv
269- New python executable in fooenv /bin/python2.6
270- Also creating executable in fooenv /bin/python
268+ $ python virtualenv .py --distribute soupenv
269+ New python executable in soupenv /bin/python2.6
270+ Also creating executable in soupenv /bin/python
271271 Installing distribute........................
272272 .............................................
273273 ...done.
@@ -280,7 +280,7 @@ When you ran that file, a couple of things took place:
280280.. class :: incremental
281281
282282* A new directory with your requested name was created
283- * A new Python executable was created in <ENV>/bin
283+ * A new Python executable was created in <ENV>/bin (<ENV>/Scripts on Windows)
284284* The new Python was cloned from the Python used to run the file
285285* The new Python was isolated from any libraries installed in the old Python
286286* Distribute (a newer, better setuptools) was installed so you have ``easy_install ``
@@ -445,20 +445,22 @@ Testing it out
445445
446446.. code-block :: python
447447
448- >> > for e in entries:
449- ... anchor = e.find(' a' )
450- ... paragraph = e.find(' p' , ' discreet' )
451- ... title = anchor.text.strip()
452- ... url = anchor.attrs[' href' ]
453- ... print title
454- ... print url
455- ... try :
456- ... print paragraph.text.strip()
457- ... except AttributeError :
458- ... print ' Uncategorized'
459- ... print
460- ...
461- >> >
448+ for e in entries:
449+ anchor = e.find(' a' )
450+ paragraph = e.find(' p' , ' discreet' )
451+ title = anchor.text.strip()
452+ url = anchor.attrs[' href' ]
453+ print title
454+ print url
455+ try :
456+ print paragraph.text.strip()
457+ except AttributeError :
458+ print ' Uncategorized'
459+ print
460+
461+ .. class :: incremental
462+
463+ Watch for unicode encoding errors, I don't get any, but you might.
462464
463465Lab 1 - 20 mins
464466---------------
@@ -477,6 +479,18 @@ Lab 1 - 20 mins
477479
478480**GO **
479481
482+ Short Break
483+ -----------
484+
485+ While you are taking a short break, you might take a moment to sign up for
486+ the geocoding service we'll use later:
487+
488+ http://geoservices.tamu.edu/UserServices/Signup.aspx
489+
490+ You can also view your profile once you've signed up:
491+
492+ http://geoservices.tamu.edu/UserServices/Profile/ViewProfile.aspx
493+
480494Another Approach
481495----------------
482496
@@ -575,7 +589,7 @@ we also allow *calling procedures* at an endpoint?
575589
576590.. class :: incremental
577591
578- We can! Enter XML-RPC
592+ We can! Enter XML-RPC (Remote Procedure Call)
579593
580594.. class :: incremental
581595
@@ -730,8 +744,8 @@ First, implement required methods on your service class:
730744 f = getattr (self , method)
731745 return f.__doc__
732746
733- XML-RPC Instrospection
734- ----------------------
747+ XML-RPC Introspection
748+ ---------------------
735749
736750Then enable introspection via the server instance:
737751
@@ -754,6 +768,26 @@ your service offers:
754768 public_method
755769 this method is public
756770
771+ Introspection Question
772+ ----------------------
773+
774+ I told you when we added the ``_private_method `` that any method that any
775+ method whose name starts with ``_ `` would be **private **.
776+
777+ .. class :: incremental
778+
779+ But we also added a ``_listMethods `` method and a ``_methodHelp `` method and
780+ *those * methods are listed when you run ``proxy.system.listMethods() ``
781+
782+ .. class :: incremental
783+
784+ Why is this?
785+
786+ .. class :: incremental
787+
788+ For a complete discussion of this, read `this MOTW post `_
789+
790+ .. _this MOTW post : http://www.doughellmann.com/PyMOTW/SimpleXMLRPCServer/index.html#introspection-api
757791
758792Beyond XML-RPC
759793--------------
@@ -896,17 +930,17 @@ required according to api documentation, it is safest to provide them all:
896930.. code-block :: python
897931 :class : small
898932
899- >> > apiKey = ' <fill this in>'
900- >> > args = {' apiKey' : apiKey, }
901- >> > args[' streetAddress' ] = ' 1325 4th Avenue'
902- >> > args[' city' ] = ' Seattle'
903- >> > args[' state' ] = ' WA'
904- >> > args[' zip' ] = ' 98101'
905- >> > args[' version' ] = 3.01
906- >> > args[' shouldReturnReferenceGeometry' ] = True
907- >> > args[' shouldNotStoreTransactionDetails' ] = True
908- >> > args[' shouldCalculateCensus' ] = False
909- >> > args[' censusYear' ] = " TwoThousandTen"
933+ apiKey = ' <fill this in>'
934+ args = {' apiKey' : apiKey, }
935+ args[' streetAddress' ] = ' 1325 4th Avenue'
936+ args[' city' ] = ' Seattle'
937+ args[' state' ] = ' WA'
938+ args[' zip' ] = ' 98101'
939+ args[' version' ] = 3.01
940+ args[' shouldReturnReferenceGeometry' ] = True
941+ args[' shouldNotStoreTransactionDetails' ] = True
942+ args[' shouldCalculateCensus' ] = False
943+ args[' censusYear' ] = " TwoThousandTen"
910944
911945 Making the Call
912946---------------
@@ -1074,11 +1108,11 @@ pythonic, no?
10741108JSON Data Types
10751109---------------
10761110
1077- JSON provides a few basic data types:
1111+ JSON provides a few basic data types (see http://json.org/) :
10781112
10791113.. class :: incremental
10801114
1081- * string: unicode, anything but '"', ' \' and control chars
1115+ * string: unicode, anything but ", \\ and control characters
10821116* number: any number, but json does not use octal or hexidecimal
10831117* object, array (we've seen these above)
10841118* true
@@ -1126,7 +1160,7 @@ You can encode python to json, and decode json back to python:
11261160 >> > array = [1 ,2 ,3 ]
11271161 >> > json.dumps(array)
11281162 >> > orig = {' foo' : [1 ,2 ,3 ], ' bar' : u ' my resumé' , ' baz' : True }
1129- >> > encoded = json.dumps(dict_ )
1163+ >> > encoded = json.dumps(orig )
11301164 >> > encoded
11311165 ' {"baz": true, "foo": [1, 2, 3], "bar": "my resum\\ u00e9"}'
11321166 >> > decoded = json.loads(encoded)
0 commit comments