You might find these discussions enlightening: http://reinout.vanrees.org/weblog/2009/07/02/ep-metaprogramming.html http://pycon.blip.tv/file/1949345 http://www.artima.com/weblogs/viewpost.jsp?thread=240808 http://www.artima.com/weblogs/viewpost.jsp?thread=240845
On Thu, Jul 23, 2009 at 5:30 PM, Delaney Burke <[email protected]>wrote: > Much apreciated and thank you for getting back to me so quicklly. I will > read up about decorators. > > Sent from my iPhone > > On 23 Jul 2009, at 21:55, Yarko Tymciurak <[email protected]> wrote: > > First, I have to admit I only know about the global.asax file from > (basically) here: <http://en.wikipedia.org/wiki/Global.asax> > http://en.wikipedia.org/wiki/Global.asax > > In web2py, wne a sequest comes in with no direction (just top URI), web2py > will look for an applicaiton "init", or if not found then an application > "welcome". Once the default app is found, the models are read in to setup > context, and the default controller is searched for an index function. > > Those are the default basics. You can modify this with the routes.py file, > but for now just be aware there is a way to map requests. > > Now, when a session starts, and you go to the selected controller-function, > it is executed. The way to enforce that a user is to ensure they are > logged in. In python you do this with so-called decorators, which are > basically functions that wrap the functions they precede (that's a bit of an > oversimplification, but a useful concept). > > To accomplish what you want in web2py, you would use the authentication > system, and precede each of your functions ("pages") that require login > such: > > @auth.requires_login() > def index(): > # your code > > See <http://www.web2py.com/examples/default/tools> > http://www.web2py.com/examples/default/tools for a bit more. > > On Thu, Jul 23, 2009 at 2:17 PM, Delaney < <[email protected]> > [email protected]> wrote: > >> >> Hi guys! i am new to web2py but so far very very impressed! I have >> come form <http://asp.net>asp.net background and I am trying to find a >> similar concept >> to the global.asax file in web2py. effectively i want the user to be >> automatically redirected to the logon screen on session start , is >> that possible or have i missed something! Any help would be mch >> appreciated. >> >> >> > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" 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 -~----------~----~----~----~------~----~------~--~---

