Provide city and state information for a buddy
The adapter needs a postal-lookup utility. For the sake of the example, we'll install one, but first, we have to set up the component architecture:
>>> from zope.app.testing import placelesssetup, ztapi >>> placelesssetup.setUp()
and then we can provide the utility:
>>> from stubpostal import Lookup >>> ztapi.provideUtility(IPostalLookup, Lookup())
Now, we can try our adapter. If we have no postal code, we get no data:
>>> bob = Buddy('Bob') >>> info = BuddyCityState(bob) >>> info.city, info.state ('', '')
But if we use a known postal code:
>>> bob = Buddy('Bob', '', '', '', '22401') >>> info = BuddyCityState(bob) >>> info.city, info.state ('Fredericksburg', 'Virginia')
Finally, we'll put things back the way we found them:
>>> placelesssetup.tearDown()
There are no base classes.
There are no attributes in this class.
There are no methods in this class.
There are no known subclasses.