I thought there is a way I can use db.table.field.requires= in models (with auth.user.id) so I could implement in my app new tools and some features of t2 at the same time.
Maybe I even can but I forgot about @auth.. statement above the function, using table, which fields I want to require something. Who knows.. I'll check it when I get back home. That was basically my problem, probably lame one, but still, your answer was helpfull. Thanks. On 3/5/09, mdipierro <[email protected]> wrote: > > I am not sure I see the problem, you just do this > > if auth.is_logged_in(): > # you can use auth.user > else: > # auth.user is None > > or > > @auth.requires_login() > def myaction(): > # can use auth.user > > > On Mar 5, 4:01 am, Kuba Kucharski <[email protected]> wrote: >> > auth.user.id -- this is the global variable 'auth' which has a >> > variable named 'user' which in turn has a named variable called >> > 'id'. This variable is valid only after a user is logged on and it >> > refers to the id of the current user. If no one is logged in, >> > auth.user does not exist and has the value of 'None'. But None has no >> > named variable 'id' so you get an error if you try to use it. >> >> I thought it is exactly like that.. but how to make my code run long >> enough >> to log a user? :)) >> >> Does this means I can run it only inside of the controller which can be >> called by a logged user? >> >> My idea - is to put some "default" data inside auth. Is this ok? Or is it >> completely wrong. There are only register/login/logout methods I want for >> non-user, this means I will never touch this default object >> >> Hm.. How it worked in t2.. >> >> >> >> > db.auth_user.id -- this is a global SQLField definition contained in >> > the 'auth_user' table named 'id'. This is a field definition and it >> > valid whether or not anyone is logged in at the moment. It refers to >> > a column of a table and can't sit on the right-hand side of '==' since >> > it does not have a single value but refers to a column in a table. >> >> > Details upon details... These should go in a wiki somewhere... ;-) >> >> Thank you for your answer! >> >> -- >> Kuba > > > -- Sent from my mobile device Kuba --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

