On Tue, Sep 30, 2008 at 10:26 PM, pigmej <[EMAIL PROTECTED]> wrote:
>
> hey,
>
> I need to use sessions in my webpy 0.3 app with subapps, but I need to
> make session "global"
>
> Any possibility to do that?


One simplest way (but not very nice) is import the module having the
session in the place it is required.

# main.py

import subapp

urls = (
    '/foo', subapp,
    ....
)

app = web.application(urls, globals())
session = web.session.Session(app, web.session.DiskStore('sessions'))


# subapp.py

def get_session():
    import main
    return main.session

class Hello:
    def __init__(self):
         return 'Hello ' + get_session().user


Does this answer your question?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to webpy@googlegroups.com
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