List Info

Thread: Sessions




Sessions
user name
2006-04-12 11:08:00
Hello,

Possibly a stupid question. What is the proper way of using
the session
object in Pylons?
I created a new project as described in the tutorial, and
then modified
the controller like this:

# =====
from helloworld.lib.base import *

class HelloController(BaseController):
    def index(self):
        pass

    def action1(self):
        session["somekey"] =
"somevalue"
        c.session_items = str(session.items())
        m.subexec("/templ1.myt")


    def action2(self):
        c.session_items = str(session.items())
        m.subexec("/templ1.myt")
# =====

The `/templ1.myt' is just <% c.session_items %>

The items of session dictionary are not preserved from
action1 request
to action2 request.
It's Pylons 0.8, Python 2.4.2, Ubuntu Linux, browser
accepts cookies.

TIA,
Rafal


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Sessions
user name
2006-04-12 14:25:17
On Apr 12, 2006, at 4:08 AM, thirdeye wrote:

> Possibly a stupid question. What is the proper way of
using the  
> session
> object in Pylons?
> I created a new project as described in the tutorial,
and then  
> modified
> the controller like this:
>
> # =====
> from helloworld.lib.base import *
>
> class HelloController(BaseController):
>     def index(self):
>         pass
>
>     def action1(self):
>         session["somekey"] =
"somevalue"
>         c.session_items = str(session.items())
>         m.subexec("/templ1.myt")
>
>
>     def action2(self):
>         c.session_items = str(session.items())
>         m.subexec("/templ1.myt")
> # =====
>
> The `/templ1.myt' is just <% c.session_items %>
>
> The items of session dictionary are not preserved from
action1 request
> to action2 request.
> It's Pylons 0.8, Python 2.4.2, Ubuntu Linux, browser
accepts cookies.

You're close, you need to do session.save() when you want
to save the  
sessions back-end storage. Adding that will fix your
problem.

HTH,
Ben

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )