You should look into the T2 source code. The class T2 is defined in a
module. When the module is imported and instantiated you pass request,
response, session, cache, T and db to it and store references to them
as member variables.

Another way would be to execute modules, instead of importing them. I
think importing is cleaner.

Massimo

On Nov 25, 8:01 am, "José Deodoro de Oliveira Filho"
<[EMAIL PROTECTED]> wrote:
> Hi,
> You see, session, request and response are not globals "per se", they depend
> on the session you're responding to. From what I can tell the controller
> functions are "wrapped" inside an environment just before they're called and
> that's why you have those variables around. So, the way it's built, you do
> have to pass them on to the modules.
>
> Anyways, I guess I'm not the best person to answer your question, I've come
> to this conclusion because I had the same problem and I took a look at the
> web2py source code (I can see that happening in main.py and compile_app.py).
> I expect one of the experts around to have a better explanation for you.
>
> Regards,
>
> Deodoro Filho
>
> On Tue, Nov 25, 2008 at 11:19 AM, Jonathan Benn <[EMAIL PROTECTED]>wrote:
>
>
>
> > Hi all,
>
> > Is there a simple way to access the dynamic web2py global variables
> > (db, session, request, response) from inside a user defined class?
>
> > If I were to define the class inside the controller, then I'd have no
> > trouble. However, if I define the class in a separate module (i.e. in
> > the "modules" subdirectory) then I'm not able to access these globals
> > anymore from inside the class.
>
> > All I've been able to find so far is passing the global variables as
> > arguments to the constructor/methods, but this seems inelegant to me
> > since db, request, etc. are _global_ variables. Accessing them is kind
> > of like accessing logging or any other Singleton...
>
> > Thanks in advance,
>
> > --Jonathan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to