Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to get web.py sessions to work using python 2.6 on OS X
    text
    copied!<p>I can not seem to get this script to work:</p> <pre><code>import web web.config.debug=False urls = ( '/', 'hello', '/bye/', 'bye') app = web.application(urls, globals()) session = web.session.Session(app, web.session.DiskStore('sessions'), initializer={'count': 0}) class hello: def GET(self): session.count += 1 return "You visited " + str(session.count) + " pages." class bye: def GET(self): session.kill() return ("Bye, web!") if __name__ == "__main__": app.run() </code></pre> <p>This is code available from the web.py documentation page: <a href="http://webpy.org/cookbook/sessions" rel="nofollow">http://webpy.org/cookbook/sessions</a></p> <p>When I try to access the 'hello' page by going to <code>http://localhost:1234/</code>, the application returns an internal server error.</p> <p>Here is the output from the terminal upon accessing this resource:</p> <pre><code>http://0.0.0.0:1234/ Traceback (most recent call last): File "/Library/Python/2.6/site-packages/web/application.py", line 237, in process return self.handle() File "/Library/Python/2.6/site-packages/web/application.py", line 228, in handle return self._delegate(fn, self.fvars, args) File "/Library/Python/2.6/site-packages/web/application.py", line 409, in _delegate return handle_class(cls) File "/Library/Python/2.6/site-packages/web/application.py", line 385, in handle_class return tocall(*args) File "testing.py", line 15, in GET session.count += 1 File "/Library/Python/2.6/site-packages/web/session.py", line 69, in __getattr__ return getattr(self._data, name) AttributeError: 'ThreadedDict' object has no attribute 'count' 127.0.0.1:49207 - - [20/Mar/2012 20:34:01] "HTTP/1.1 GET /" - 500 Internal Server Error </code></pre> <p>Can any web.py expert out there tell me what is going on?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload