[web2py] how to reset_password_key programmatically?
hello one and all, I am trying to setup Managers, like one per firm, in which a Manager can add and update users under auth_user. only for their firm. if the manager sets up a new user or forces the user to change their password, how do I signal to web2py that the user needs to update or change their password? like I get that I can send the user an email notice with a link, which has an expiration date/time built into it, to the "user/change_password" screen but how do I set that up in code? thank you in advance. lucas -- 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.
[web2py] Re: Returning a token for Android app authentication
The only challenge im facing is the needed customization on the W2P side to allow the the app to login, and the route to use inside the mobile app to pass the login credentials. If someone can share a segment of the code it can be helpful. Thanks. Oasis On Tuesday, April 18, 2017 at 12:25:38 AM UTC+2, Dave S wrote: > > > > On Monday, April 17, 2017 at 1:16:49 PM UTC-7, Oasis Agano wrote: >> >> You mean that it doesnt require modifying core Web2py code? or adding >> other codes inside your controller? because what i want is actually logging >> in and storing a token returned by w2p. >> >> > It is already part of web2py core, in all 2.14.x versions (and maybe some > 2.13.y versions). > I haven't actually used it, but the doc comment in tools.py seems to be a > very good explanation. > (I've done some other reading on JWT -- Niphlod posted the link to the > RFC, for instance -- and > know of its use for helping to secure OAuth2.) > > I think a couple of other users have posted here that they used it now > that it's built-in. > > /dps > > > >> On Monday, April 17, 2017 at 10:05:53 PM UTC+2, Dave S wrote: >>> >>> >>> >>> On Monday, April 17, 2017 at 4:18:48 AM UTC-7, Oasis Agano wrote: Hello, Can someone create a web2pyslice explaining how to do it and what to change in web2py gluon in order to connect an android native app to it. 4 years later people(e.g: me, my colleagues...) are still facing the same issue and i think it can be helpful to the community. >>> >>> Have you looked at using JWT? Documentation is mainly gluon/tools.py, >>> although Niphlod wrote here a little about its use when he coded it a >>> couple of years ago. >>> >>> /dps >>> >>> >>> On Wednesday, October 15, 2014 at 3:48:02 AM UTC+2, Mark Li wrote: > > Hey Mark, > > I did finish this, although it's been some time since I've looked into > the code for the mobile-related stuff. Most of it still makes sense to me > > On Friday, October 10, 2014 1:31:09 PM UTC-7, Mark Graves wrote: >> >> Did you ever finish this? >> >> I implemented something similar. >> >> I'd love to collaborate and get a repo up for working with mobile >> devices with web2py as an app back end. >> >> On Sunday, January 6, 2013 11:43:05 AM UTC-6, dlypka wrote: >>> >>> If you mimic the same http traffic that a browser would generate, >>> then of course you will get all the normal web2py functionality such as >>> the >>> session. >>> >>> The web2py session is usually stored in the database which means it >>> can store a large amount of data without the size limits of cookie >>> storage. >>> And it will persist between requests. >>> >>> [...] >>> >> >>> >> -- 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.
[web2py] Saving User bandwidth consumed
Please help regarding bandwidth , how user usage of bandwidth should taken from web2py application , application requirement is to check the bandwidth size consumed per logged in user -- 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: Make web2py update tables schemas auto
Yes, I'm working with legacy tables that were already existing in MySql before you hooked your application to that databases, and I added fields to my models, and this not reflect on the db Em 19 de abr de 2017 21:28, "Dave S" escreveu: > > > On Wednesday, April 19, 2017 at 4:42:33 PM UTC-7, Áureo Dias Neto wrote: >> >> How can I make web2py recreate (alter) my tables according to my models, >> using mysql? In SQLite is is automatic, but when the 'migrate = true' >> hedge, I got an error that is an X table (all of them) also exist, also >> tried fake_migrate_all = True, not a bug in this case, but my schema Bank >> Not updated >> > > So your situation is you set up your application, ran for a while (with > the models getting MySql tables), changed the model, and want the MySql > tables to reflect the changes? Did you change field types or add fields? > > Or are you working with legacy tables that were already existing in MySql > before you hooked your application to that database? > > /dps > > > > -- > 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. > -- 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.
[web2py] Re: @auth.requires for functions
But... "any"? I need some more information about lambda I thinkwhere to find this syntax with any? where is written what you told about evaluation? Thank you very much Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: > > First, when using auth.requires(), it is best to put the test inside a > lambda (or standard function) so it will not be evaluated until the > decorated function is actually called (otherwise, the test will be > evaluated whenever the controller file is accessed). > > Anyway, you can do something like this: > > list_of_roles = ['role1', 'role2', 'role3'] # You could get this list via > a database query > > @auth.requires(lambda: any(auth.has_membership(role) for role in > list_of_roles)) > def myfunc(): > ... > > Anthony > > On Wednesday, April 19, 2017 at 8:14:53 AM UTC-4, Andrea Fae' wrote: >> >> For example I have this type of functions: >> >> # sono autorizzati i vari manager a seconda della sede >> @auth.requires(auth.has_membership('Total-manager') | >> auth.has_membership('Conegliano-studente') | >> auth.has_membership('Pordenone-manager') | >> auth.has_membership('Pordenone-studente') | >> auth.has_membership('Udine-studente')) >> def appuntamenti_studente(): >> # recupero lo studente selezionato >> studente = request.args(0) >> # recupero il gruppo >> # query per recuperare il nome dello studente >> query_nome_studente = db.auth_user.id == studente >> # recupero nome e cognome dello studente >> row = >> db(query_nome_studente).select(db.auth_user.first_name,db.auth_user.last_name).first() >> #seleziono gli eventi dello studente >> query = (db.evento.studenti.contains(studente)) >> eventi_stud = db(query).select() >> # imposto la grid per far vedere gli eventi dello studente >> exportcls = dict(csv_with_hidden_cols=False, html=False, json=False, >> tsv_with_hidden_cols=False, tsv=False) >> # solo se lo studente corrisponde a chi si è loggato >> if (str(auth.user.id) == studente): >> #print 'sono al form normale' >> form = SQLFORM.grid(query, args=[studente], >> fields=[db.evento.titolo, >> db.evento.inizio,db.evento.fine,db.evento.risorsa, >> db.evento.materia,db.evento.docente],create=False, details=False, >> editable=False, deletable=False, maxtextlength=60, exportclasses = >> exportcls) >> else: >> redirect(URL('default','index')) >> return locals() >> >> I'm testing different "fixed" values in the @auth.requires, but they can >> be more or less depending on how many roles are in the db. I'd like to do >> this dynamically from the db, extracting and compising this @auth.requires >> line in dynamic way. Is it possible? Do you have any examples? Thank you >> > -- 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.
[web2py] Re: use case: user login on android
Can someone share the code on the controller side of authentication inside web2py and how to make co exist with the default authentication. Thanks, Oasis On Tuesday, April 18, 2017 at 12:31:38 AM UTC+2, Dave S wrote: > > > > On Monday, April 17, 2017 at 1:20:20 PM UTC-7, Oasis Agano wrote: >> >> No extra modifications inside the web2py controller? I want to >> authenticate users available in a web2py application through an android app >> >> > I don't know of anything particularly unusual, but I haven't done android > apps since JellyBean. There's a package that seems to be popular around > here to run Javascript in a framework on the phone, but the normal > server-side tools should be fine. Maybe returning JSON. Web2py supports > that out of the box, and also supports REST apis, and as mentioned in the > other thread has support for JWT. The web2py auth mechanisms are fairly > flexible. > > /dps > > > >> On Monday, April 17, 2017 at 10:07:24 PM UTC+2, Dave S wrote: >>> >>> >>> >>> On Monday, April 17, 2017 at 4:08:29 AM UTC-7, Oasis Agano wrote: Can Someone write a slice on how to connect an android app to a web2py server, using java and py >>> >>> >>> Android end just has to do GET and POST, innit? >>> >>> /dps >>> >>> -- 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.requires for functions
https://docs.python.org/2/library/functions.html#any def any(iterable): for element in iterable: if element: return True return False so any() return true if one (or more) of the elements is True. this: auth.has_membership(role) for role in list_of_roles try all the roles in the list. so if one of the auth.has_membership() return true, the lamba function return true. 2017-04-20 14:36 GMT+02:00 Andrea Fae' : > But... "any"? I need some more information about lambda I thinkwhere > to find this syntax with any? > where is written what you told about evaluation? > Thank you very much > > > Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: >> >> First, when using auth.requires(), it is best to put the test inside a >> lambda (or standard function) so it will not be evaluated until the >> decorated function is actually called (otherwise, the test will be >> evaluated whenever the controller file is accessed). >> >> Anyway, you can do something like this: >> >> list_of_roles = ['role1', 'role2', 'role3'] # You could get this list >> via a database query >> >> @auth.requires(lambda: any(auth.has_membership(role) for role in >> list_of_roles)) >> def myfunc(): >> ... >> >> Anthony >> >> On Wednesday, April 19, 2017 at 8:14:53 AM UTC-4, Andrea Fae' wrote: >>> >>> For example I have this type of functions: >>> >>> # sono autorizzati i vari manager a seconda della sede >>> @auth.requires(auth.has_membership('Total-manager') | >>> auth.has_membership('Conegliano-studente') | >>> auth.has_membership('Pordenone-manager') | >>> auth.has_membership('Pordenone-studente') | >>> auth.has_membership('Udine-studente')) >>> def appuntamenti_studente(): >>> # recupero lo studente selezionato >>> studente = request.args(0) >>> # recupero il gruppo >>> # query per recuperare il nome dello studente >>> query_nome_studente = db.auth_user.id == studente >>> # recupero nome e cognome dello studente >>> row = db(query_nome_studente).select(db.auth_user.first_name,db. >>> auth_user.last_name).first() >>> #seleziono gli eventi dello studente >>> query = (db.evento.studenti.contains(studente)) >>> eventi_stud = db(query).select() >>> # imposto la grid per far vedere gli eventi dello studente >>> exportcls = dict(csv_with_hidden_cols=False, html=False, >>> json=False, tsv_with_hidden_cols=False, tsv=False) >>> # solo se lo studente corrisponde a chi si è loggato >>> if (str(auth.user.id) == studente): >>> #print 'sono al form normale' >>> form = SQLFORM.grid(query, args=[studente], >>> fields=[db.evento.titolo, db.evento.inizio,db.evento.fine,db.evento.risorsa, >>> db.evento.materia,db.evento.docente],create=False, details=False, >>> editable=False, deletable=False, maxtextlength=60, exportclasses = >>> exportcls) >>> else: >>> redirect(URL('default','index')) >>> return locals() >>> >>> I'm testing different "fixed" values in the @auth.requires, but they can >>> be more or less depending on how many roles are in the db. I'd like to do >>> this dynamically from the db, extracting and compising this @auth.requires >>> line in dynamic way. Is it possible? Do you have any examples? Thank you >>> >> -- > 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. > -- 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.requires for functions
Thanks Il giorno giovedì 20 aprile 2017 15:40:33 UTC+2, Marvix ha scritto: > > https://docs.python.org/2/library/functions.html#any > > def any(iterable): > for element in iterable: > if element: > return True > return False > > so any() return true if one (or more) of the elements is True. > > > this: > > auth.has_membership(role) for role in list_of_roles > > try all the roles in the list. > > so if one of the auth.has_membership() return true, the lamba function return > true. > > > > 2017-04-20 14:36 GMT+02:00 Andrea Fae' >: > >> But... "any"? I need some more information about lambda I thinkwhere >> to find this syntax with any? >> where is written what you told about evaluation? >> Thank you very much >> >> >> Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: >>> >>> First, when using auth.requires(), it is best to put the test inside a >>> lambda (or standard function) so it will not be evaluated until the >>> decorated function is actually called (otherwise, the test will be >>> evaluated whenever the controller file is accessed). >>> >>> Anyway, you can do something like this: >>> >>> list_of_roles = ['role1', 'role2', 'role3'] # You could get this list >>> via a database query >>> >>> @auth.requires(lambda: any(auth.has_membership(role) for role in >>> list_of_roles)) >>> def myfunc(): >>> ... >>> >>> Anthony >>> >>> On Wednesday, April 19, 2017 at 8:14:53 AM UTC-4, Andrea Fae' wrote: For example I have this type of functions: # sono autorizzati i vari manager a seconda della sede @auth.requires(auth.has_membership('Total-manager') | auth.has_membership('Conegliano-studente') | auth.has_membership('Pordenone-manager') | auth.has_membership('Pordenone-studente') | auth.has_membership('Udine-studente')) def appuntamenti_studente(): # recupero lo studente selezionato studente = request.args(0) # recupero il gruppo # query per recuperare il nome dello studente query_nome_studente = db.auth_user.id == studente # recupero nome e cognome dello studente row = db(query_nome_studente).select(db.auth_user.first_name,db.auth_user.last_name).first() #seleziono gli eventi dello studente query = (db.evento.studenti.contains(studente)) eventi_stud = db(query).select() # imposto la grid per far vedere gli eventi dello studente exportcls = dict(csv_with_hidden_cols=False, html=False, json=False, tsv_with_hidden_cols=False, tsv=False) # solo se lo studente corrisponde a chi si è loggato if (str(auth.user.id) == studente): #print 'sono al form normale' form = SQLFORM.grid(query, args=[studente], fields=[db.evento.titolo, db.evento.inizio,db.evento.fine,db.evento.risorsa, db.evento.materia, db.evento.docente],create=False, details=False, editable=False, deletable=False, maxtextlength=60, exportclasses = exportcls) else: redirect(URL('default','index')) return locals() I'm testing different "fixed" values in the @auth.requires, but they can be more or less depending on how many roles are in the db. I'd like to do this dynamically from the db, extracting and compising this @auth.requires line in dynamic way. Is it possible? Do you have any examples? Thank you >>> -- >> 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+un...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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: Make web2py update tables schemas auto
In fact, I migrated my application from sqlite to mysql .. -- 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.
[web2py] Image in grid
Hello. Is there a way to display an image in a grid? Model: db.define_table('schemes', Field('name', type='string', requires=IS_NOT_EMPTY()), Field('description', type='string'), Field('image_file', 'upload')) Thanks. -- 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: Make web2py update tables schemas auto
On Thursday, April 20, 2017 at 6:49:06 AM UTC-4, Áureo Dias Neto wrote: > > Yes, I'm working with legacy tables that were already existing in MySql > before you hooked your application to that databases, and I added fields to > my models, and this not reflect on the db > If you never used web2py to do any migrations, then web2py doesn't know about the current state of your database -- you have to run fake_migrate to let it know that your model definitions reflect the current database schema. From that point on, you can enable migrations, and model changes will be propagated to the database schema (for the most part -- changes to things like "notnull" and "unique" will not affect the database, as those attributes can only be specified when web2py first creates the table). If you changed your Bank model without changing its database schema and then run fake_migrate, web2py will not update the schema in the database. That is the point of fake_migrate -- you are only telling web2py to update its metadata about the database state -- it assumes the database is already in that state. If you want web2py to actually change the database, run fake_migrate with the *old* Bank model. Then turn on migrations and change the Bank model, and web2py will make the change in the database schema. Also, note that there is no difference in how web2py treats SQLite or MySQL with regard to migrations being automatic. If you use web2py to create the tables to begin with, web2py will handle everything automatically from the start, whichever database you use. On the other hand, if you start with an existing database, you must start with a set of models that reflect the current database schema and run fake_migrate so web2py knows the state of the database. From that point, web2py can manage migrations. Anthony -- 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.
[web2py] Re: @auth.requires for functions
On Thursday, April 20, 2017 at 8:36:46 AM UTC-4, Andrea Fae' wrote: > > But... "any"? I need some more information about lambda I thinkwhere > to find this syntax with any? > where is written what you told about evaluation? > Remember, web2py is a Python framework -- many of the things you see are simply Python (both "any" and "lambda" are plain Python constructs). Note, it doesn't have to be a lambda function -- the point is simply that if you pass a function of any kind to auth.requires(), it will call that function *later* (when the function it decorates is actually called) rather than *immediately* (when the decorator itself is defined -- which happens whenever the controller file is executed). So, by putting the test inside a function, you defer the execution of the test until it is actually needed. Because the auth.has_membership() calls each require a database select, you don't want to run those calls unless absolutely necessary. This recommendation is mentioned here: http://web2py.com/books/default/chapter/29/09/access-control#Decorators. Anthony -- 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: Make web2py update tables schemas auto
The problem was that I actually modified the sql to migrate the database, because some fields CHAR (512) from sqlite, I had to switch to TEXT in mysql I'm going to hold a fake_migration .. Thank you Anthony. 2017-04-20 11:06 GMT-03:00 Anthony : > On Thursday, April 20, 2017 at 6:49:06 AM UTC-4, Áureo Dias Neto wrote: >> >> Yes, I'm working with legacy tables that were already existing in MySql >> before you hooked your application to that databases, and I added fields to >> my models, and this not reflect on the db >> > > If you never used web2py to do any migrations, then web2py doesn't know > about the current state of your database -- you have to run fake_migrate to > let it know that your model definitions reflect the current database > schema. From that point on, you can enable migrations, and model changes > will be propagated to the database schema (for the most part -- changes to > things like "notnull" and "unique" will not affect the database, as those > attributes can only be specified when web2py first creates the table). > > If you changed your Bank model without changing its database schema and > then run fake_migrate, web2py will not update the schema in the database. > That is the point of fake_migrate -- you are only telling web2py to update > its metadata about the database state -- it assumes the database is already > in that state. If you want web2py to actually change the database, run > fake_migrate with the *old* Bank model. Then turn on migrations and > change the Bank model, and web2py will make the change in the database > schema. > > Also, note that there is no difference in how web2py treats SQLite or > MySQL with regard to migrations being automatic. If you use web2py to > create the tables to begin with, web2py will handle everything > automatically from the start, whichever database you use. On the other > hand, if you start with an existing database, you must start with a set of > models that reflect the current database schema and run fake_migrate so > web2py knows the state of the database. From that point, web2py can manage > migrations. > > Anthony > > -- > 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. > -- 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: Using validate_and_insert with a computed field
On Wednesday, April 19, 2017 at 7:50:46 PM UTC-4, Chris wrote: > > Uh oh...I just removed requires from the computed field and reran my unit > tests, and now validate_and_insert inserts but the computed field isn't > calculated at all! I tried insert and it does the computation. > > Is there some reason validate_and_insert would not compute where insert > does? > The computed field will not get a value if any of the fields needed by the compute function are missing. Also, I notice that when .validate_and_insert() is called, if any of the fields are set to None, they end up getting dropped before being passed to .insert() (this should probably be considered a bug). So, if you are setting a field needed by the compute function to None, then that would cause the compute to fail. If that's not your situation, then you'll have to show more code to diagnose the problem. Anthony -- 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.
[web2py] Re: @auth.requires for functions
Hello, if I have to get the list from database, where I need to put the code? At the start of default.py where I use the functions? Thanks Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: > > First, when using auth.requires(), it is best to put the test inside a > lambda (or standard function) so it will not be evaluated until the > decorated function is actually called (otherwise, the test will be > evaluated whenever the controller file is accessed). > > Anyway, you can do something like this: > > list_of_roles = ['role1', 'role2', 'role3'] # You could get this list via > a database query > > @auth.requires(lambda: any(auth.has_membership(role) for role in > list_of_roles)) > def myfunc(): > ... > > Anthony > > On Wednesday, April 19, 2017 at 8:14:53 AM UTC-4, Andrea Fae' wrote: >> >> For example I have this type of functions: >> >> # sono autorizzati i vari manager a seconda della sede >> @auth.requires(auth.has_membership('Total-manager') | >> auth.has_membership('Conegliano-studente') | >> auth.has_membership('Pordenone-manager') | >> auth.has_membership('Pordenone-studente') | >> auth.has_membership('Udine-studente')) >> def appuntamenti_studente(): >> # recupero lo studente selezionato >> studente = request.args(0) >> # recupero il gruppo >> # query per recuperare il nome dello studente >> query_nome_studente = db.auth_user.id == studente >> # recupero nome e cognome dello studente >> row = >> db(query_nome_studente).select(db.auth_user.first_name,db.auth_user.last_name).first() >> #seleziono gli eventi dello studente >> query = (db.evento.studenti.contains(studente)) >> eventi_stud = db(query).select() >> # imposto la grid per far vedere gli eventi dello studente >> exportcls = dict(csv_with_hidden_cols=False, html=False, json=False, >> tsv_with_hidden_cols=False, tsv=False) >> # solo se lo studente corrisponde a chi si è loggato >> if (str(auth.user.id) == studente): >> #print 'sono al form normale' >> form = SQLFORM.grid(query, args=[studente], >> fields=[db.evento.titolo, >> db.evento.inizio,db.evento.fine,db.evento.risorsa, >> db.evento.materia,db.evento.docente],create=False, details=False, >> editable=False, deletable=False, maxtextlength=60, exportclasses = >> exportcls) >> else: >> redirect(URL('default','index')) >> return locals() >> >> I'm testing different "fixed" values in the @auth.requires, but they can >> be more or less depending on how many roles are in the db. I'd like to do >> this dynamically from the db, extracting and compising this @auth.requires >> line in dynamic way. Is it possible? Do you have any examples? Thank you >> > -- 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.
[web2py] Re: use case: user login on android
On Thursday, April 20, 2017 at 6:30:15 AM UTC-7, Oasis Agano wrote: > > Can someone share the code on the controller side of authentication inside > web2py and how to make co exist with the default authentication. > > The web2py side can be handled with a decorator if Basic Auth is sufficient; see http://web2py.com/books/default/chapter/29/09/access-control#Access-Control-and-Basic-Authentication> The android side would be a GET with the (Base64 encoded) credentials. Base64 isn't encryption, but if you're using HTTPS the transport provides the encryption. You can also do other forms of login (two factor, CAS, etc) as one step , issue a JWT, and then use the JWT in the [REST] API calls. See the JWT intro in gluon/tools.py. /dps > On Tuesday, April 18, 2017 at 12:31:38 AM UTC+2, Dave S wrote: >> >> >> >> On Monday, April 17, 2017 at 1:20:20 PM UTC-7, Oasis Agano wrote: >>> >>> No extra modifications inside the web2py controller? I want to >>> authenticate users available in a web2py application through an android app >>> >>> >> I don't know of anything particularly unusual, but I haven't done android >> apps since JellyBean. There's a package that seems to be popular around >> here to run Javascript in a framework on the phone, but the normal >> server-side tools should be fine. Maybe returning JSON. Web2py supports >> that out of the box, and also supports REST apis, and as mentioned in the >> other thread has support for JWT. The web2py auth mechanisms are fairly >> flexible. >> >> /dps >> >> >> >>> On Monday, April 17, 2017 at 10:07:24 PM UTC+2, Dave S wrote: On Monday, April 17, 2017 at 4:08:29 AM UTC-7, Oasis Agano wrote: > > Can Someone write a slice on how to connect an android app to a web2py > server, using java and py > Android end just has to do GET and POST, innit? /dps -- 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.
[web2py] Re: Saving User bandwidth consumed
On Thursday, April 20, 2017 at 3:02:49 AM UTC-7, Sharjeel Ali Shaukat wrote: > > Please help regarding bandwidth , how user usage of bandwidth should taken > from web2py application , application requirement is to check the bandwidth > size consumed per logged in user > This seems like something you'd have to get from the front end (Apache? Nginx?). I would think that the front end would have a way to communicate this to the application, where it could be recorded, but I don't know any details. The application should be able to estimate how many bytes it might send to the user (that would be volume, not rate) but only for the parts it is responsible for, and not any bytes the front end might use to wrap the response. The size of a file being downloaded is easily available, the size of a dynamically generated response (forms, query results, etc) might be more fiddly to track. /dps -- 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.
[web2py] Re: Returning a token for Android app authentication
On Thursday, April 20, 2017 at 2:57:44 AM UTC-7, Oasis Agano wrote: > > > The only challenge im facing is the needed customization on the W2P side > to allow the the app to login, and the route to use inside the mobile app > to pass the login credentials. > If someone can share a segment of the code it can be helpful. > Thanks. > > Discussed in the other thread (maybe even answered). /dps > On Tuesday, April 18, 2017 at 12:25:38 AM UTC+2, Dave S wrote: >> >> >> >> On Monday, April 17, 2017 at 1:16:49 PM UTC-7, Oasis Agano wrote: >>> >>> You mean that it doesnt require modifying core Web2py code? or adding >>> other codes inside your controller? because what i want is actually logging >>> in and storing a token returned by w2p. >>> >>> >> It is already part of web2py core, in all 2.14.x versions (and maybe some >> 2.13.y versions). >> I haven't actually used it, but the doc comment in tools.py seems to be a >> very good explanation. >> (I've done some other reading on JWT -- Niphlod posted the link to the >> RFC, for instance -- and >> know of its use for helping to secure OAuth2.) >> >> I think a couple of other users have posted here that they used it now >> that it's built-in. >> >> /dps >> >> >> >>> On Monday, April 17, 2017 at 10:05:53 PM UTC+2, Dave S wrote: On Monday, April 17, 2017 at 4:18:48 AM UTC-7, Oasis Agano wrote: > > Hello, > Can someone create a web2pyslice explaining how to do it and what to > change in web2py gluon in order to connect an android native app to it. > 4 years later people(e.g: me, my colleagues...) are still facing the > same issue and i think it can be helpful to the community. > Have you looked at using JWT? Documentation is mainly gluon/tools.py, although Niphlod wrote here a little about its use when he coded it a couple of years ago. /dps > On Wednesday, October 15, 2014 at 3:48:02 AM UTC+2, Mark Li wrote: >> >> Hey Mark, >> >> I did finish this, although it's been some time since I've looked >> into the code for the mobile-related stuff. Most of it still makes sense >> to >> me >> >> On Friday, October 10, 2014 1:31:09 PM UTC-7, Mark Graves wrote: >>> >>> Did you ever finish this? >>> >>> I implemented something similar. >>> >>> I'd love to collaborate and get a repo up for working with mobile >>> devices with web2py as an app back end. >>> >>> On Sunday, January 6, 2013 11:43:05 AM UTC-6, dlypka wrote: If you mimic the same http traffic that a browser would generate, then of course you will get all the normal web2py functionality such as the session. The web2py session is usually stored in the database which means it can store a large amount of data without the size limits of cookie storage. And it will persist between requests. [...] >>> >>> -- 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.
[web2py] Date selector doesn't display properly after changing layout(see screenshot).What can be the reason?
Any idea on what must be wrong in any of the external css file in the layout. What I should do to rectify this? -- 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.
[web2py] Re: use case: user login on android
Thank you for the reply, does basic auth return a token? it seems that basic auth works on that time but isnt persistent, i mean if i try to open another link requiring authentication i get redirected to the login. in a git repo of an android app using w2p as a server i saw the guy connected using this route: final String url = initial + "/default/login.json?userid=" + username + "&password=" + password; but i think that was a custom function. On Thursday, April 20, 2017 at 8:56:43 PM UTC+2, Dave S wrote: > > > > On Thursday, April 20, 2017 at 6:30:15 AM UTC-7, Oasis Agano wrote: >> >> Can someone share the code on the controller side of authentication >> inside web2py and how to make co exist with the default authentication. >> >> The web2py side can be handled with a decorator if Basic Auth is > sufficient; see > > http://web2py.com/books/default/chapter/29/09/access-control#Access-Control-and-Basic-Authentication > > > > The android side would be a GET with the (Base64 encoded) credentials. > Base64 isn't encryption, but if you're using HTTPS the transport provides > the encryption. > > You can also do other forms of login (two factor, CAS, etc) as one step , > issue a JWT, and then use the JWT in the [REST] API calls. See the JWT > intro in gluon/tools.py. > > /dps > > > > >> On Tuesday, April 18, 2017 at 12:31:38 AM UTC+2, Dave S wrote: >>> >>> >>> >>> On Monday, April 17, 2017 at 1:20:20 PM UTC-7, Oasis Agano wrote: No extra modifications inside the web2py controller? I want to authenticate users available in a web2py application through an android app >>> I don't know of anything particularly unusual, but I haven't done >>> android apps since JellyBean. There's a package that seems to be popular >>> around here to run Javascript in a framework on the phone, but the normal >>> server-side tools should be fine. Maybe returning JSON. Web2py supports >>> that out of the box, and also supports REST apis, and as mentioned in the >>> other thread has support for JWT. The web2py auth mechanisms are fairly >>> flexible. >>> >>> /dps >>> >>> >>> On Monday, April 17, 2017 at 10:07:24 PM UTC+2, Dave S wrote: > > > > On Monday, April 17, 2017 at 4:08:29 AM UTC-7, Oasis Agano wrote: >> >> Can Someone write a slice on how to connect an android app to a >> web2py server, using java and py >> > > > Android end just has to do GET and POST, innit? > > /dps > > -- 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.
[web2py] Re: Image in grid
*pls try :* def schemes(): table = db.schemes links = [dict(header = T('Image'), body = lambda row_field: \ DIV(A(IMG(_src = URL('default', 'download', args = row_field), _width = 150, _height = 100), _href = URL('default', 'download', args = row_field) ) if row_field else '' ) ) ] grid = SQLFORM.grid(table, links = links) return locals() best regards, stifan -- 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: Using validate_and_insert with a computed field
I'm not sure if this is the cause of your problem, but I just posted an issue: https://github.com/web2py/pydal/issues/462 Anthony On Thursday, April 20, 2017 at 10:30:14 AM UTC-4, Anthony wrote: > > On Wednesday, April 19, 2017 at 7:50:46 PM UTC-4, Chris wrote: >> >> Uh oh...I just removed requires from the computed field and reran my unit >> tests, and now validate_and_insert inserts but the computed field isn't >> calculated at all! I tried insert and it does the computation. >> >> Is there some reason validate_and_insert would not compute where insert >> does? >> > > The computed field will not get a value if any of the fields needed by the > compute function are missing. Also, I notice that when > .validate_and_insert() is called, if any of the fields are set to None, > they end up getting dropped before being passed to .insert() (this should > probably be considered a bug). So, if you are setting a field needed by the > compute function to None, then that would cause the compute to fail. If > that's not your situation, then you'll have to show more code to diagnose > the problem. > > Anthony > -- 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: Using validate_and_insert with a computed field
Thanks for the update! I'm passing all of the fields needed by the compute function. It looks something like this: dct_new_user = { fields here } # new_user = db.auth_user.insert(**dct_new_user) new_user = db.auth_user.validate_and_insert(**dct_new_user) The former calculates the computed field, but the latter does not. On Thursday, April 20, 2017 at 7:57:12 PM UTC-4, Anthony wrote: > > I'm not sure if this is the cause of your problem, but I just posted an > issue: https://github.com/web2py/pydal/issues/462 > > Anthony > > On Thursday, April 20, 2017 at 10:30:14 AM UTC-4, Anthony wrote: >> >> On Wednesday, April 19, 2017 at 7:50:46 PM UTC-4, Chris wrote: >>> >>> Uh oh...I just removed requires from the computed field and reran my >>> unit tests, and now validate_and_insert inserts but the computed field >>> isn't calculated at all! I tried insert and it does the computation. >>> >>> Is there some reason validate_and_insert would not compute where insert >>> does? >>> >> >> The computed field will not get a value if any of the fields needed by >> the compute function are missing. Also, I notice that when >> .validate_and_insert() is called, if any of the fields are set to None, >> they end up getting dropped before being passed to .insert() (this should >> probably be considered a bug). So, if you are setting a field needed by the >> compute function to None, then that would cause the compute to fail. If >> that's not your situation, then you'll have to show more code to diagnose >> the problem. >> >> Anthony >> > -- 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: Using validate_and_insert with a computed field
Need to see the fields. -- 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.
[web2py] Re: how to reset_password_key programmatically?
ok, this is what I figured out from the source code under gluon.tools. I have a form with a nonSQLFORM input that allows the Manager to optionally force the user to reset the password. if that form is submitted correctly, under the form.process().accepted I have: rv = request.vars sent = "" if (rv.active == "T") or ((xUser is not None) and (xUser.email <> uform.vars.email)): xUser.update_record(email=uform.vars.email, password=db.auth_user.password.validate('any_random_string')[0]) sent = sent and auth.email_reset_password(xUser) if sent: sent = " and Email Sent" session.flash = "User Added/Updated"+sent where xUser and uform is a db query and SQLFORM, respectively, for the user that the Manager is working on. the main idea is that xUser is update_record with the new email and an encrypted random string and then auth.email_reset_password will also update_record with the proper reset_password_key string and store all three fields in the database. it will then notify the user through an email the full link with the reset_password_key to the user and the user can then update their password under the link. can also customize the subject and body of the email sent under db.py via: auth.default_messages['reset_password_subject'] = "XYZ: Update your Changed Email/Password" auth.default_messages['reset_password'] = "Login User/Email and/or Password have changed for your XYZ account. Click on the link: %(link)s to reset your password. Please choose a different password then used prior hand." pretty smooth and I think it is working properly. anyone can offer further details. lucas -- 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.