On 3/18/09, Noragen <noragen@gmx.net> wrote:
Hi,

i have two following problems:

1. problem:
I make an import from a python module in a PSPPage.
In this python i want to have following globals like req and res (request and response and perhaps other global stuff i dont remember yet)

from a psp-page i can surely call the script with script(self) to get the objects within the script like
def script(self)
    self.response().write("anytext")
    self.request().session.set("sessionparam","blub")

but anyhow it is something like stupid to do it in every function less then have this in a global context.

Tobias,
If I understand your question correctly you actually don't want a global contact because then that context would be shared with all other threads running in the appserver and you'd have requests overwritting that context. You really want a per thread context (which is per active request). Since an instance of the Servlet is created for each thread, you can assign data to the Servlet or your page instance and access it in the methods of that PSPPage subclass. So within the page "self" is your global context (but be certain to clear it at the beginning or end of each page to transaction to avoid accessing stale data in that thread).

Best Regards,
Steve