well i cant this damned thing to work. why cant i just do i.target=i.source anyway? it works in javascript.
why does it send me to another page. i dont want that at all. no update page either. just take text from one box, insert into another. i can take the text from the upper box with i=web.input() and i.source. so that works. is insert really the function for this? it is what redirects to a new site right? and why am i getting errors: whats wrogn witht he notation. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <title>robber's language</title> <style type="text/css"> <!-- body { margin: 0px; padding: 0px; } #header { background: #FDD017; width: 100%; height: 10%; font-size: xx-large; text-align: center; } #content { background: white; float: right; width: 100%; height: 90%; text-align: center; } a:link {color: black; } a:visited {color: white; } a:hover {color: black; } a:active {color: black; } --> </style> </head> <body> <div id="header"> <b>Robber's language encrypter/decrypter</b> </div> <div id="content"> <form method=post> <div><textarea name="source" cols="60" rows="10"></textarea></ div> <div><input type="submit" value="translate"></div> <div><textarea name="target" cols="60" rows="10"></textarea></ div> </form> </div> </body> </html> import web import rob render = web.template.render('templates/') urls = ( '/', 'main', ) class main: def GET(self): print render.main() def POST(self): i = web.input() #phrase = i.source #print phrase #i.target=i.source n = web.insert("target", i.source) web.webapi.internalerror = web.debugerror if __name__ == "__main__": web.run(urls, globals()) <type 'exceptions.AttributeError'> at / 'db_cursor' Python C:\Python25\lib\site-packages\web\utils.py in __getattr__, line 54 Web POST http://localhost:8080/ Traceback (innermost first) * C:\Python25\lib\site-packages\web\utils.py in __getattr__ 47. AttributeError: 'a' 48. 49. """ 50. def __getattr__(self, key): 51. try: 52. return self[key] 53. except KeyError, k: 54. raise AttributeError, k ... 55. 56. def __setattr__(self, key, value): 57. self[key] = value 58. 59. def __delattr__(self, key): 60. try: ▶ Local vars Variable Value k KeyError('db_cursor',) key 'db_cursor' self <Storage {'status': '200 OK', 'homedomain': 'http://localhost: 8080', 'protocol': 'http', 'ip': '127.0.0.1', 'fullpath': '/', 'headers': [('Content-Type', 'text/html')], 'host': 'localhost:8080', 'environ': {'AUTH_TYPE': '', 'HTTP_REFERER': 'http://localhost:8080/', 'SERVER_SOFTWARE': 'CherryPy/3.0.1 WSGI Server', 'SCRIPT_NAME': '', 'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1', 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/', 'SERVER_PROTOCOL': 'HTTP/1.1', 'QUERY_STRING': '', 'CONTENT_LENGTH': '20', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'HTTP_CONNECTION': 'keep-alive', 'REMOTE_PORT': '49955', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.url_scheme': 'http', 'SERVER_PORT': '8080', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'wsgi.input': <socket._fileobject object at 0x0200AE70>, 'HTTP_HOST': 'localhost:8080', 'wsgi.multithread': True, 'HTTP_ACCEPT': 'text/xml,application/ xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/ *;q=0.5', 'wsgi.version': (1, 0), 'wsgi.run_once': False, 'wsgi.errors': <idlelib.rpc.RPCProxy object at 0x01B7B050>, 'wsgi.multiprocess': False, 'HTTP_ACCEPT_LANGUAGE': 'sv,en- us;q=0.7,en;q=0.3', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_KEEP_ALIVE': '300'}, 'env': {'AUTH_TYPE': '', 'HTTP_REFERER': 'http://localhost:8080/', 'SERVER_SOFTWARE': 'CherryPy/3.0.1 WSGI Server', 'SCRIPT_NAME': '', 'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1', 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/', 'SERVER_PROTOCOL': 'HTTP/ 1.1', 'QUERY_STRING': '', 'CONTENT_LENGTH': '20', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE; rv: 1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'HTTP_CONNECTION': 'keep- alive', 'REMOTE_PORT': '49955', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.url_scheme': 'http', 'SERVER_PORT': '8080', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'wsgi.input': <socket._fileobject object at 0x0200AE70>, 'HTTP_HOST': 'localhost:8080', 'wsgi.multithread': True, 'HTTP_ACCEPT': 'text/ xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/ plain;q=0.8,image/png,*/*;q=0.5', 'wsgi.version': (1, 0), 'wsgi.run_once': False, 'wsgi.errors': <idlelib.rpc.RPCProxy object at 0x01B7B050>, 'wsgi.multiprocess': False, 'HTTP_ACCEPT_LANGUAGE': 'sv,en-us;q=0.7,en;q=0.3', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_KEEP_ALIVE': '300'}, 'home': 'http://localhost:8080', 'homepath': '', 'output': '', 'path': '/', 'query': '', 'data': 'source=super&target=', 'method': 'POST'}> * C:\Python25\lib\site-packages\web\utils.py in __getattr__ 700. of the threadeddict, it passes it on to the object 701. for that thread in dictionary. 702. """ 703. def __init__(self, dictionary): 704. self.__dict__['_ThreadedDict__d'] = dictionary 705. 706. def __getattr__(self, attr): 707. return getattr(self.__d[threading.currentThread()], attr) ... 708. 709. def __getitem__(self, item): 710. return self.__d[threading.currentThread()][item] 711. 712. def __setattr__(self, attr, value): 713. if attr == '__doc__': ▶ Local vars Variable Value attr 'db_cursor' self <Storage {'status': '200 OK', 'homedomain': 'http://localhost: 8080', 'protocol': 'http', 'ip': '127.0.0.1', 'fullpath': '/', 'headers': [('Content-Type', 'text/html')], 'host': 'localhost:8080', 'environ': {'AUTH_TYPE': '', 'HTTP_REFERER': 'http://localhost:8080/', 'SERVER_SOFTWARE': 'CherryPy/3.0.1 WSGI Server', 'SCRIPT_NAME': '', 'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1', 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/', 'SERVER_PROTOCOL': 'HTTP/1.1', 'QUERY_STRING': '', 'CONTENT_LENGTH': '20', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'HTTP_CONNECTION': 'keep-alive', 'REMOTE_PORT': '49955', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.url_scheme': 'http', 'SERVER_PORT': '8080', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'wsgi.input': <socket._fileobject object at 0x0200AE70>, 'HTTP_HOST': 'localhost:8080', 'wsgi.multithread': True, 'HTTP_ACCEPT': 'text/xml,application/ xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/ *;q=0.5', 'wsgi.version': (1, 0), 'wsgi.run_once': False, 'wsgi.errors': <idlelib.rpc.RPCProxy object at 0x01B7B050>, 'wsgi.multiprocess': False, 'HTTP_ACCEPT_LANGUAGE': 'sv,en- us;q=0.7,en;q=0.3', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_KEEP_ALIVE': '300'}, 'env': {'AUTH_TYPE': '', 'HTTP_REFERER': 'http://localhost:8080/', 'SERVER_SOFTWARE': 'CherryPy/3.0.1 WSGI Server', 'SCRIPT_NAME': '', 'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1', 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/', 'SERVER_PROTOCOL': 'HTTP/ 1.1', 'QUERY_STRING': '', 'CONTENT_LENGTH': '20', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE; rv: 1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'HTTP_CONNECTION': 'keep- alive', 'REMOTE_PORT': '49955', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.url_scheme': 'http', 'SERVER_PORT': '8080', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'wsgi.input': <socket._fileobject object at 0x0200AE70>, 'HTTP_HOST': 'localhost:8080', 'wsgi.multithread': True, 'HTTP_ACCEPT': 'text/ xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/ plain;q=0.8,image/png,*/*;q=0.5', 'wsgi.version': (1, 0), 'wsgi.run_once': False, 'wsgi.errors': <idlelib.rpc.RPCProxy object at 0x01B7B050>, 'wsgi.multiprocess': False, 'HTTP_ACCEPT_LANGUAGE': 'sv,en-us;q=0.7,en;q=0.3', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_KEEP_ALIVE': '300'}, 'home': 'http://localhost:8080', 'homepath': '', 'output': '', 'path': '/', 'query': '', 'data': 'source=super&target=', 'method': 'POST'}> * C:\Python25\lib\site-packages\web\db.py in insert 620. ', '.join([aparam() for x in values]) 621. ), values.values()) 622. else: 623. sql_query = SQLQuery("INSERT INTO %s DEFAULT VALUES" % tablename) 624. 625. if _test: return sql_query 626. 627. db_cursor = web.ctx.db_cursor() ... 628. if seqname is False: 629. pass 630. elif web.ctx.db_name == "postgres": 631. if seqname is None: 632. seqname = tablename + "_id_seq" 633. sql_query += "; SELECT currval('%s')" % seqname ▶ Local vars Variable Value _test False seqname 'super' sql_query <sql: 'INSERT INTO target DEFAULT VALUES'> tablename 'target' values {} * C:\Python25\myPrograms\webapps\robberlang\roblangweb.py in POST 11. print render.main() 12. 13. def POST(self): 14. i = web.input() 15. #phrase = i.source 16. #print phrase 17. #i.target=i.source 18. n = web.insert("target", i.source) ... 19. 20. web.webapi.internalerror = web.debugerror 21. if __name__ == "__main__": web.run(urls, globals()) ▶ Local vars Variable Value i <Storage {'source': 'super', 'target': ''}> self <__main__.main instance at 0x020186E8> * C:\Python25\lib\site-packages\web\request.py in handle 53. meth = "GET" 54. if not hasattr(cls, meth): 55. return nomethod(cls) 56. tocall = getattr(cls(), meth) 57. args = list(result.groups()) 58. for d in re.findall(r'\\(\d+)', ofn): 59. args.pop(int(d) - 1) 60. return tocall(*([x and urllib.unquote(x) for x in args] + fna)) ... 61. 62. return web.notfound() 63. 64. def nomethod(cls): 65. """Returns a `405 Method Not Allowed` error for `cls`.""" 66. web.ctx.status = '405 Method Not Allowed' ▶ Local vars Variable Value args [] cls <class __main__.main at 0x01FD6180> fn 'main' fna [] fvars {'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__name__': '__main__', 'main': <class __main__.main at 0x01FD6180>, 'render': <web.template.render instance at 0x01FD5F80>, 'rob': <module 'rob' from 'C:\Python25\myPrograms\webapps\robberlang \rob.pyc'>, 'urls': ('/', 'main'), 'web': <module 'web' from 'C: \Python25\lib\site-packages\web\__init__.pyc'>} mapping ('/', 'main') meth 'POST' mod {'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__name__': '__main__', 'main': <class __main__.main at 0x01FD6180>, 'render': <web.template.render instance at 0x01FD5F80>, 'rob': <module 'rob' from 'C:\Python25\myPrograms\webapps\robberlang \rob.pyc'>, 'urls': ('/', 'main'), 'web': <module 'web' from 'C: \Python25\lib\site-packages\web\__init__.pyc'>} ofn 'main' ofno 'main' result <_sre.SRE_Match object at 0x02028720> tocall <bound method main.POST of <__main__.main instance at 0x020186E8>> url '/' * C:\Python25\lib\site-packages\web\request.py in <lambda> 123. return name 124. 125. mod = __import__(modname(), None, None, [""]) 126. #@@probably should replace this with some inspect magic 127. name = utils.dictfind(fvars, inp) 128. func = lambda: handle(getattr(mod, name), mod) 129. else: 130. func = lambda: handle(inp, fvars) ... 131. else: 132. func = inp 133. return func 134. 135. def run(inp, fvars, *middleware): 136. """ ▶ Local vars Variable Value fvars {'__builtins__': <module '__builtin__' (built-in)>, '__doc__': None, '__name__': '__main__', 'main': <class __main__.main at 0x01FD6180>, 'render': <web.template.render instance at 0x01FD5F80>, 'rob': <module 'rob' from 'C:\Python25\myPrograms\webapps\robberlang \rob.pyc'>, 'urls': ('/', 'main'), 'web': <module 'web' from 'C: \Python25\lib\site-packages\web\__init__.pyc'>} inp ('/', 'main') * C:\Python25\lib\site-packages\web\webapi.py in wsgifunc 304. _load(env) 305. 306. # allow uppercase methods only 307. if ctx.method.upper() != ctx.method: 308. return notfound() 309. 310. try: 311. result = func() ... 312. except StopIteration: 313. result = None 314. except: 315. print >> debug, traceback.format_exc() 316. result = internalerror() 317. ▶ Local vars Variable Value env {'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1', 'AUTH_TYPE': '', 'CONTENT_LENGTH': '20', 'CONTENT_TYPE': 'application/x-www-form- urlencoded', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml +xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'sv,en- us;q=0.7,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'localhost:8080', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http:// localhost:8080/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'PATH_INFO': '/', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '49955', 'REQUEST_METHOD': 'POST', 'SCRIPT_NAME': '', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'CherryPy/3.0.1 WSGI Server', 'wsgi.errors': <idlelib.rpc.RPCProxy object at 0x01B7B050>, 'wsgi.input': <socket._fileobject object at 0x0200AE70>, 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)} func <function <lambda> at 0x01FCA9F0> start_resp <function xstart_response at 0x0200ADB0> Response so far HEADERS Content-Type: text/html BODY Request information INPUT Variable Value source 'super' target '' COOKIES No data. META Variable Value Content-Type 'text/html' ENVIRONMENT Variable Value ACTUAL_SERVER_PROTOCOL 'HTTP/1.1' AUTH_TYPE '' CONTENT_LENGTH '20' CONTENT_TYPE 'application/x-www-form-urlencoded' HTTP_ACCEPT 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/ plain;q=0.8,image/png,*/*;q=0.5' HTTP_ACCEPT_CHARSET 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' HTTP_ACCEPT_ENCODING 'gzip,deflate' HTTP_ACCEPT_LANGUAGE 'sv,en-us;q=0.7,en;q=0.3' HTTP_CONNECTION 'keep-alive' HTTP_HOST 'localhost:8080' HTTP_KEEP_ALIVE '300' HTTP_REFERER 'http://localhost:8080/' HTTP_USER_AGENT 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE; rv:1.8.1.14) Gecko/ 20080404 Firefox/2.0.0.14' PATH_INFO '/' QUERY_STRING '' REMOTE_ADDR '127.0.0.1' REMOTE_PORT '49955' REQUEST_METHOD 'POST' SCRIPT_NAME '' SERVER_NAME 'localhost' SERVER_PORT '8080' SERVER_PROTOCOL 'HTTP/1.1' SERVER_SOFTWARE 'CherryPy/3.0.1 WSGI Server' wsgi.errors <idlelib.rpc.RPCProxy object at 0x01B7B050> wsgi.input <socket._fileobject object at 0x0200AE70> wsgi.multiprocess False wsgi.multithread True wsgi.run_once False wsgi.url_scheme 'http' wsgi.version (1, 0) You're seeing this error because you have web.internalerror set to web.debugerror. Change that if you want a different one. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
