Yeah it works now. Thanks very much Bruce much appreciated. Still have
quite a bit to learn about all of this stuff.
On Thursday, 5 July 2012 21:32:10 UTC+1, Bruce Wade wrote:
>
> It shouldn't look at your javascript console, if you are using ajax to
> call this.
>
> On Thu, Jul 5, 2012 at 1:30 PM, adohertyd wrote:
>
>> Thanks Bruce will try that. Why does 'return blekkoresults' work though?
>>
>>
>> On Thursday, 5 July 2012 21:24:53 UTC+1, Bruce Wade wrote:
>>
>>> Ok exactly it is complaining that {{=results}} does not exist.
>>>
>>> Reneed to return dict(results=something) from your results action in
>>> your controller
>>>
>>> On Thu, Jul 5, 2012 at 1:23 PM, adohertyd wrote:
>>>
>>> This is my results.html, all of it :)
>>>>
>>>> {{extend 'layout.html'}}
>>>>
>>>> {{=results}}
>>>>
>>>> On Thursday, 5 July 2012 21:20:59 UTC+1, Bruce Wade wrote:
>>>>
>>>>> I am assuming by your error inside results.html you have a variable
>>>>> defined as results however you are passing a tuple
>>>>> blekkoresults,bingresults we would need to see results.html
>>>>>
>>>>> On Thu, Jul 5, 2012 at 1:16 PM, adohertyd wrote:
>>>>>
>>>>> No tried that and got 'unsupported format character 'A' at index 7'
>>>>>>
>>>>>>
>>>>>> On Thursday, 5 July 2012 21:08:20 UTC+1, Richard wrote:
>>>>>>
>>>>>>> Maybe you should encode your bing url.
>>>>>>>
>>>>>>> Richard
>>>>>>>
>>>>>>> On Thu, Jul 5, 2012 at 4:05 PM, adohertyd wrote:
>>>>>>>
>>>>>>> I am trying to get a json response from 2 URL's and showing in on a
>>>>>>>> results page. I'm getting an error saying that the page I'm
>>>>>>>> redirecting to
>>>>>>>> in order to show the json data is not defined but this only happens
>>>>>>>> with
>>>>>>>> one of the url's being contacted. I'm probably not being very clear
>>>>>>>> with
>>>>>>>> this so I will show you some code:
>>>>>>>>
>>>>>>>>
>>>>>>>> import urllib2
>>>>>>>>
>>>>>>>> def index():
>>>>>>>> form = FORM(''...
>>>>>>>> if form.process().accepted:
>>>>>>>> session.term=request.vars.**quer****y
>>>>>>>> redirect(URL('results'))
>>>>>>>> elif form.errors: ...
>>>>>>>> return dict(form=form)
>>>>>>>>
>>>>>>>> def __process():
>>>>>>>> term = session.term
>>>>>>>> term = urllib2.quote("'" + term + "'")
>>>>>>>> return dict(term=term)
>>>>>>>>
>>>>>>>> def results():
>>>>>>>> import requests
>>>>>>>>
>>>>>>>> blekko = "http://www.blekko.com/?q=%(**te****rm)s+/json&auth=
>>>>>>>> <mykey>" % __process()
>>>>>>>> blekkoresults = urllib2.urlopen(blekko).read()
>>>>>>>>
>>>>>>>> bing = "https://api.datamarket.azure.******
>>>>>>>> com/Data.ashx/Bing/SearchWeb/**W****eb?Query=%(term)s&$top=50&$**
>>>>>>>> for****mat=json"
>>>>>>>> API_KEY = 'mykey'
>>>>>>>> r = requests.get(bing % __process(), auth=('', API_KEY))
>>>>>>>> bingresults = r.json
>>>>>>>>
>>>>>>>> return blekkoresults, bingresults
>>>>>>>>
>>>>>>>> The line 'bing= ' is causing the issue. If I comment out the bing
>>>>>>>> section of the code, the blekko part returns no problem. However, with
>>>>>>>> the
>>>>>>>> bing section included I get the following error:
>>>>>>>>
>>>>>>>> 1.
>>>>>>>> 2.
>>>>>>>> 3.
>>>>>>>> 4.
>>>>>>>> 5.
>>>>>>>> 6.
>>>>>>>>
>>>>>>>> Traceback (most recent call last):
>>>>>>>> File "C:\web2py\gluon\restricted.**py****", line 205, in restricted
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> exec ccode in environment
>>>>>>>> File
>>>>>>>> "C:\web2py\applications\**metase****arch2\views\manage/**results.**htm**l",
>>>>>>>> line 86, in <module>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> NameError: name 'results' is not defined
>>>>>>>>
>>>>>>>> Can anyone please tell me what's going on? If I run this program in
>>>>>>>> IDLE it returns the bing results so it is definitely a web2py issue.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> --
>>>>> Regards,
>>>>> Bruce Wade
>>>>> http://ca.linkedin.com/in/**bruc**elwade<http://ca.linkedin.com/in/brucelwade>
>>>>> http://www.wadecybertech.com
>>>>> http://www.fittraineronline.**co**m <http://www.fittraineronline.com>-
>>>>> Fitness Personal Trainers Online
>>>>> http://www.warplydesigned.com
>>>>>
>>>>>
>>>
>>>
>>> --
>>> --
>>> Regards,
>>> Bruce Wade
>>> http://ca.linkedin.com/in/**brucelwade<http://ca.linkedin.com/in/brucelwade>
>>> http://www.wadecybertech.com
>>> http://www.fittraineronline.**com <http://www.fittraineronline.com> -
>>> Fitness Personal Trainers Online
>>> http://www.warplydesigned.com
>>>
>>>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>