DOh.. I figured out my problem.

Once you have a session established (even if you restart the computer)
you have to kill() it before you can add more attributes.

On Aug 1, 9:13 am, Cowmix <[email protected]> wrote:
> When I change 'count' to 'mary' I get the attribute error below:
>
> 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={'mary':0})
>
> class count:
>     def GET(self):
>         session.mary+= 1
>         return ((session.mary))
>
> class reset:
>     def GET(self):
>         session.kill()
>         return ""
>
> if __name__ == "__main__":
>     app.run()
>
> (NEW)mma...@secure:~/PYTHON$ python test2.pyhttp://0.0.0.0:8080/
> Traceback (most recent call last):
>   File "/home/mmarch/PYTHON/NEW/lib/python2.6/site-packages/web/
> application.py", line 242, in process
>     return self.handle()
>   File "/home/mmarch/PYTHON/NEW/lib/python2.6/site-packages/web/
> application.py", line 233, in handle
>     return self._delegate(fn, self.fvars, args)
>   File "/home/mmarch/PYTHON/NEW/lib/python2.6/site-packages/web/
> application.py", line 412, in _delegate
>     return handle_class(cls)
>   File "/home/mmarch/PYTHON/NEW/lib/python2.6/site-packages/web/
> application.py", line 387, in handle_class
>     return tocall(*args)
>   File "test2.py", line 13, in GET
>     session.mary+= 1
>   File "/home/mmarch/PYTHON/NEW/lib/python2.6/site-packages/web/
> utils.py", line 923, in __getattr__
>     return getattr(self._getd(), key)
>   File "/home/mmarch/PYTHON/NEW/lib/python2.6/site-packages/web/
> utils.py", line 68, in __getattr__
>     raise AttributeError, k
> AttributeError: 'mary'
>
> On Aug 1, 6:49 am, Branko Vukelic <[email protected]> wrote:
>
> > On Sat, 2009-08-01 at 04:09 -0700, Steve Matyas wrote:
> > > Branko,
>
> > > Hmm.. I just tried the following locally and it worked.
>
> > Of course. That's because you _initialized_ `bob`. OP initialized
> > `count`, and then tried to use += operator on `bob`. That's not
> > possible.
>
> > --
> > Branko
>
> > eml: [email protected]
> > alt: [email protected]
> > blg:http://sudologic.blogspot.com/
> > img:http://picasaweb.google.com/bg.branko
> > twt:http://www.twitter.com/foxbunny/
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to