[web2py] embeded python code in web2py raise error

2012-08-16 Thread Hojat Taheri
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 URLErro

[web2py] url validator

2012-08-15 Thread Hojat Taheri
in a shorten-er built by web2by i want to validate url's first, if it's not valid goes back to the first page with an error message. this is my code in controller (mvc arch.) but i don't get what's wrong..!! import urllib def index(): return dict() def random_maker(): url = request.vars.url