That's the thing, I don't know where it is being called or why! I haven't specified it, so I'm assuming it's coming from this block of code:
import requests bing = " https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%(term)s&$top=50&$format=json " API_KEY= 'mykey' term = __process() r = requests.get(URL % {'term': urllib.quote(term)}, auth=('', API_KEY)) bingresults = r.json['d']['results'] On Thursday, 5 July 2012 15:12:20 UTC+1, Jonathan Lundell wrote: > > On 5 Jul 2012, at 6:55 AM, adohertyd wrote: > > Me again! I don't know why I am getting this error. The process() function > takes in a value session.term, processes it, and returns it as a dict type > so that it can be mapped to URL's in the next function. The results() > function sends the variable 'term' to 3 different API URL's which all > should return some json results. The entireweb and blekko results come back > fine if I leave out the bing call; however, the bing results cause the > error 'Dict object has no attribute rstrip'. The problem has to be in the > way I'm calling the Bing API. Would really appreciate some guidance here. > Thanks! This is my default.py controller > > > Where is rstrip being called, and on which variable? > > One thing: avoid using URL as a variable name. The symbol is globally > defined in web2py as the URL function you're calling in index(). You might > be getting away with it here, but best to use another name. > > > def index(): > form = FORM('', > INPUT(_name='query', requires=IS_NOT_EMPTY()), > INPUT(_type='submit')) > if form.process().accepted: > session.term=request.vars.query > redirect(URL('results')) > elif form.errors: > response.flash = 'form has errors' > else: > response.flash = 'please fill the form' > return dict(form=form) > > def __process(): > import urllib > term=session.term > #do some processing on term > return dict(term=term) > > def results(): > import urllib > import requests #This is an external library in the site-packages > folder > > blekko = "http://www.blekko.com/?q=%(term)s+/json&auth=f4c8acf3" > %__process > () > blekkoresults = urllib.urlopen(blekko).read() > > entireweb = " > http://www.entireweb.com/xmlquery?pz=<mykey>&ip=<myIP>&n=10&of=0&format=json&q=%(term)s > " %__process() > entresults = urllib.urlopen(entireweb).read() > > URL = " > https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%(term)s&$top=50&$format=json > " > API_KEY= 'mykey' > term = __process() > r = requests.get(URL % {'term': urllib.quote(term)}, auth=('', API_KEY > )) > bingresults = r.json['d']['results'] > > return blekkoresults, entresults, bingresults > > > > > > > >