Re: [web2py] Re: Auth question
Rahul Let's try this a different way. Attached is a simple multi-tenant app with one table. Does this do what you need? 1. Create a new project in web2py 2. Replace db.py in your models dir with this one 3. Replace default.py in your controllers dir with this one 4. Replace index.html in views/default with this one 5. Add notes.html to views/default 6. Replace storage.sqlite in your databases dir with this one Depending on your version of web2py this should all work. I've created 2 logins elvis - password is password blueeyes - password is password Click on the notes link logged in as each of them and you'll see different notes show up based on the common filter. -Jim On Sat, Oct 27, 2018 at 12:52 PM Rahul wrote: > Hi Dave and Jim, >Please find the files in the zipped archive. I have added > default.py, db.py, index.html and also layout file which I am converting to > use with web2py. called ace.html. I have also attached the views\login.html > file since I am extending this file specifically for login form as it is > different than layout file. Let me know. Thanks! > > > Regards, > > Rahul > > On Friday, October 26, 2018 at 5:11:12 PM UTC+5:30, Jim S wrote: >> >> Can you show the entire db.py, default py and index.html? >> >> Jim >> >> >> On Fri, Oct 26, 2018, 1:44 AM Rahul wrote: >> >>> Nope - doesnt help. I commented out all the user functions defined in >>> the controller and >>> >>> >>> # User functions --- >>> '''def login(): return dict(form=auth.login()) >>> def register(): return dict(form=auth.register()) >>> def retrieve_password(): return dict(form=auth.reset_password()) >>> def logout(): return dict(form=auth.logout()) >>> def profile(): return dict(form=auth.profile()) >>> ''' >>> >>> I even decorated index - It does take me to the login screen but from >>> there nothing happens. It just wont log me in like it did before. Also, I >>> have two users in database but none work now. Again, register seems to >>> fail (It did work earlier) but now it doesnt. See screenshot of both >>> screens. Looks like I must be really doing something weird. If this wont >>> work by this Sunday. I may go back to my old style of coding and do it all >>> by myself. I've seriously lost 10 days reading and experimenting with Auth >>> to make it work . Not too much coded. >>> >>> @auth.requires_login() >>> def index(): >>> response.flash = T("Hello User") >>> #redirect(URL(r=request, c='default/user', f='login')) # Redirects >>> user to login page >>> return dict(message=T('Welcome to web2py!')) >>> >>> >>> >>> Thanks, >>> >>> Rahul >>> >>> >>> >>> On Thursday, October 25, 2018 at 6:02:45 PM UTC+5:30, Jim S wrote: Having the default user() functions is all you need. I'd try commenting out your 'user' functions. -Jim On Wednesday, October 24, 2018 at 10:59:45 PM UTC-5, Rahul wrote: > > Yes this is in default.py. Please excuse me for my bad code as I am > still experimenting with Auth and not totally familiar with the > implementation. Is this the right way that I am doing it? or only having > user() function is enough ? > > Thanks, Rahul > > On Wednesday, October 24, 2018 at 9:45:21 PM UTC+5:30, Jim S wrote: >> >> I'm confused. Is this code in your controller somewhere? >> >> # User functions --- >> def login(): return dict(form=auth.login()) >> def register(): return dict(form=auth.register()) >> def retrieve_password(): return dict(form=auth.reset_password()) >> def logout(): return dict(form=auth.logout()) >> def profile(): return dict(form=auth.profile()) >> >> You shouldn't need it. To override the default login stuff I've just >> modified the one in default.py. >> >> -Jim >> >> >> >> On Tuesday, October 23, 2018 at 11:26:45 PM UTC-5, Rahul wrote: >>> >>> The user function remains as-is - No modifications done. >>> >>> def user(): >>> """ >>> exposes: >>> http:///[app]/default/user/login >>> http:///[app]/default/user/logout >>> http:///[app]/default/user/register >>> http:///[app]/default/user/profile >>> http:///[app]/default/user/retrieve_password >>> http:///[app]/default/user/change_password >>> http:///[app]/default/user/bulk_register >>> use @auth.requires_login() >>> @auth.requires_membership('group name') >>> @auth.requires_permission('read','table name',record_id) >>> to decorate functions that need access control >>> also notice there is http:///[app]/appadmin/manage/auth to >>> allow administrator to manage users >>> """ >>> return dict(form=auth()) >>> >>> I am using the specified functions to expose methods as below - >>> # User functions --- >>> def login(): return dict(form=auth.login()) >>>
[web2py] is field representation changed from web2py 2.14.6?
with this model (very simplified) db.define_table('table1', Field('first_field' ), format='%(first_field)s' ) db.define_table('table2', Field('field_one' ), Field('field_two','reference table1' ) db.table2.field_one.represent = lambda value, row: CAT (row.field_two) returns *table1 id *in web2py 2.14.6 and *table1 first_field* (i.e. table1 format) in web2py 2.17.2 Is this intentional? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Auth question
Hi Dave and Jim, Please find the files in the zipped archive. I have added default.py, db.py, index.html and also layout file which I am converting to use with web2py. called ace.html. I have also attached the views\login.html file since I am extending this file specifically for login form as it is different than layout file. Let me know. Thanks! Regards, Rahul On Friday, October 26, 2018 at 5:11:12 PM UTC+5:30, Jim S wrote: > > Can you show the entire db.py, default py and index.html? > > Jim > > > On Fri, Oct 26, 2018, 1:44 AM Rahul > > wrote: > >> Nope - doesnt help. I commented out all the user functions defined in the >> controller and >> >> >> # User functions --- >> '''def login(): return dict(form=auth.login()) >> def register(): return dict(form=auth.register()) >> def retrieve_password(): return dict(form=auth.reset_password()) >> def logout(): return dict(form=auth.logout()) >> def profile(): return dict(form=auth.profile()) >> ''' >> >> I even decorated index - It does take me to the login screen but from >> there nothing happens. It just wont log me in like it did before. Also, I >> have two users in database but none work now. Again, register seems to >> fail (It did work earlier) but now it doesnt. See screenshot of both >> screens. Looks like I must be really doing something weird. If this wont >> work by this Sunday. I may go back to my old style of coding and do it all >> by myself. I've seriously lost 10 days reading and experimenting with Auth >> to make it work . Not too much coded. >> >> @auth.requires_login() >> def index(): >> response.flash = T("Hello User") >> #redirect(URL(r=request, c='default/user', f='login')) # Redirects >> user to login page >> return dict(message=T('Welcome to web2py!')) >> >> >> >> Thanks, >> >> Rahul >> >> >> >> On Thursday, October 25, 2018 at 6:02:45 PM UTC+5:30, Jim S wrote: >>> >>> Having the default user() functions is all you need. I'd try commenting >>> out your 'user' functions. >>> >>> -Jim >>> >>> On Wednesday, October 24, 2018 at 10:59:45 PM UTC-5, Rahul wrote: Yes this is in default.py. Please excuse me for my bad code as I am still experimenting with Auth and not totally familiar with the implementation. Is this the right way that I am doing it? or only having user() function is enough ? Thanks, Rahul On Wednesday, October 24, 2018 at 9:45:21 PM UTC+5:30, Jim S wrote: > > I'm confused. Is this code in your controller somewhere? > > # User functions --- > def login(): return dict(form=auth.login()) > def register(): return dict(form=auth.register()) > def retrieve_password(): return dict(form=auth.reset_password()) > def logout(): return dict(form=auth.logout()) > def profile(): return dict(form=auth.profile()) > > You shouldn't need it. To override the default login stuff I've just > modified the one in default.py. > > -Jim > > > > On Tuesday, October 23, 2018 at 11:26:45 PM UTC-5, Rahul wrote: >> >> The user function remains as-is - No modifications done. >> >> def user(): >> """ >> exposes: >> http:///[app]/default/user/login >> http:///[app]/default/user/logout >> http:///[app]/default/user/register >> http:///[app]/default/user/profile >> http:///[app]/default/user/retrieve_password >> http:///[app]/default/user/change_password >> http:///[app]/default/user/bulk_register >> use @auth.requires_login() >> @auth.requires_membership('group name') >> @auth.requires_permission('read','table name',record_id) >> to decorate functions that need access control >> also notice there is http:///[app]/appadmin/manage/auth to >> allow administrator to manage users >> """ >> return dict(form=auth()) >> >> I am using the specified functions to expose methods as below - >> # User functions --- >> def login(): return dict(form=auth.login()) >> def register(): return dict(form=auth.register()) >> def retrieve_password(): return dict(form=auth.reset_password()) >> def logout(): return dict(form=auth.logout()) >> def profile(): return dict(form=auth.profile()) >> >> >> >> and the corresponding files reside in \views\ *not in* >> \views\default - I am not sure if the application is even picking up >> these >> files. >> >> Note - I have extended the Auth (auth_user) table and added workspace >> and other fields - This will be specified everytime I add a new user. I >> would filter out the results as you mentioned but only after all the >> login >> stuff works properly. >> >> auth.settings.extra_fields['auth_user'] = [ >> Field ('workspace', length=128), >> >> Sincerely, >
[web2py] No module named states
There is no module in contrib called "states". Why are you expecting one? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.