we can't tell what the problem is from the pasted code (aside from 
indentation that was probably messed up in copy/paste).

can you show us an example of your default.py file and the traceback you 
are getting with the error?

On Thursday, August 16, 2012 12:29:25 AM UTC-7, Hojat Taheri wrote:
>
> hi, not to waste time, plz tell me how should i use this code in 
> controller default.py :
> it works in python well but in web2py error..error..error
>
>
> from urllib2 import Request, urlopen, URLError
>
> url = request.vars.url
> req = Request(url)
>     try:
>         response = urlopen(req)
>     except URLError, e:
>         if hasattr(e, 'reason'):
>             print 'We failed to reach a server.'
>             print 'Reason: ', e.reason
>         elif hasattr(e, 'code'):
>             print 'The server couldn\'t fulfill the request.'
>             print 'Error code: ', e.code
>         else:
>             print 'URL is good!'
>
>
>
>
>

-- 



Reply via email to