Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:29:53+00:00 2026-06-04T01:29:53+00:00

I just ran this simple code snippet provided by the wiki, because I couldn’t

  • 0

I just ran this simple code snippet provided by the wiki, because I couldn’t get sessions working:

import web
web.config.debug = False
urls = (
    "/count", "count",
    "/reset", "reset"
)
app = web.application(urls, locals())
session = web.session.Session(app, web.session.DiskStore('sessions'), initializer={'count': 0})

class count:
    def GET(self):
        session.count += 1
        return str(session.count)

class reset:
    def GET(self):
        session.kill()
        return ""

if __name__ == "__main__":
    app.run()

But it results in this error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 237, in process
    return self.handle()
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 228, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 411, in _delegate
    return handle_class(cls)
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 387, in handle_class
    return tocall(*args)
  File "temp.py", line 12, in GET
    session.count += 1
  File "/usr/local/lib/python2.7/dist-packages/web/session.py", line 71, in __getattr__
    return getattr(self._data, name)
AttributeError: 'ThreadedDict' object has no attribute 'count'

Is webpy not compatible with 2.7.3? I’m running this on the internal webserver of webpy. I’m using Ubuntu 12.04.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:29:54+00:00Added an answer on June 4, 2026 at 1:29 am

    session.count += 1 is equal to session.count = session.count + 1 so session.count must exist for this to work.

    Add the following check to make it work:

    if 'count' not in session:
        session.count = 0
    session.count += 1
    

    There is also another way which is even shown in the very simple session simple example of the docs:

    try:
        s.click += 1
    except AttributeError:
        s.click = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just ran this simple code through the w3c validation service ( http://validator.w3.org/check ).
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran
I am just getting started with NHaml and ran into a snag. This is
In Visual Studio 2008 Team System, I just ran Code Analysis (from the Analyze
I am just learning how to use perl hashes and ran into this message
I have a quite strange situation. I have this very simple package: Task get
I just ran into a problem with the version of JAX-WS in JDK 1.6.0
I just ran across a question with an answer suggesting the AntiXss library to
I just ran across an issue that probably exposes my ignorance of common threading
I just ran into a SQL query with about 5 different columns in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.