[web2py] Re: How to cause radio buttons to auto deselect?
i have used @auth.requires_login() before def index(): which works perfectly,i.e.,first you have to login to give some input.. But i want to save in my database how many people and their information in a database.. How may i do it? Pls help asap -- 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: Arbitrary args/kwargs with service?
On Thursday, January 5, 2017 at 7:04:56 AM UTC-8, Anthony wrote: > > But from the other side of things, I guess the question is, if we can do >> that, is there ever any reason to use the "service" mechanism at all? Or >> can request.restful do everything service can do, and more? >> > > I suppose their use cases are overlapping. If @request.restful works for > you in this case, then use it. The @service mechanism lets you easily > expose functions for use in remote procedure calls, including via > standardized RPC protocols. The @service decorators also automatically > return the correct response format, whereas @request.restful requires the > use of the generic views (disabled by default) to automatically generate > different response formats (though it will automatically generate JSON if > the request specifies "application/json"). > > Anthony > I guess the request.restful approach works better for me at this point. Is there a way to tell web2py to enable generic views only for restful controller functions, and disable them otherwise? In continuing to explore both approaches, I gained a better understanding of my problem with the service approach, and I want to share it here because I think it is worth thinking about in terms of the design of web2py. The problem I have with the service approach is that it seems to make impossible to use a decorator to wrap a service controller function in order to add or remove arguments, because the service function will "block" web2py from seeing what arguments the real service function accepts, causing web2py to pass the wrong arguments. There is a certain Python idiom that goes something like this: def accept_extra_arg(func): def wrapper(extra_arg, *args, **kwargs): # maybe do something with extra_arg here result = func(*args, **kwargs) # maybe do something with extra_arg here return result return wrapper @accept_extra_arg def foo(x, y): return x+y The idea is that the accept_extra_arg decorator allows you to wrap your function with a handler that accepts an extra argument which the function does not see, but which is used to preprocess the function's arguments and/or postprocess its result. In the case of web APIs, for instance, this is a natural way to do something like write a series of API functions that require an API key to be used: you can have a @requires_key decorator that wraps functions, allowing the function itself to be "pure" and just concentrate on returning the data, without having to handle the checking of the API key. There is a related idiom which is the reverse, involving writing a decorator that accepts an argument and returns a decorated function accepting *fewer* arguments that the original, allowing a behavior akin to functools.partial, by which some arguments are specified in advance via the decorator, rather than being passed on each call to the decorated function. The web2py service mechanism breaks this idiom. The problem is that because the wrapped function is supposed to be agnostic as to the arguments of the function it wraps, it just accepts *args and **kwargs (in addition to its extra argument). This means that web2py won't pass it anything. This kind of breaks the RPC idea that calling the function internally should be the same as calling it via the network API: if my function wants to use *args and/or **kwargs, web2py apparently doesn't provide a way for me to use it in a seamless manner for internal vs external calls. I *think* I have been able to get around this with request.restful, because it passes everything along without trying to match the arguments. But it is somewhat annoying for the case of read-only APIs because of the extra layer of indirection required (returning a function that returns the data, rather than just returning the data). What I really want is the ability to write an arbitrary function, accepting arbitrary arguments. I want the ability to wrap that function with decorators that absorb or add arguments as I please. And then I want to be able to expose that arbitrarily wrapped function as a service endpoint (presumably by wrapping the function with a web2py decorator as the last one). I don't want any of the decorators nor the original function ever to have to worry about *how* the arguments are being passed (e.g., positionally or by keyword), and I don't want any function in the chain to ever have to worry about the number or names of any arguments other than the ones it explicitly processes from the arguments passed to it. So, basically, I want to be able to use decorators the same way I would use them in ordinary Python code, and not have web2py step in at some point and disrupt the process by which decorated functions pass their arguments to the functions they wrap. Now, that's not to say that I don't appreciate the tools web2py does offer. I've found them quite powerful. A
[web2py] Re: Python Social Auth - example site working with downlevel version of PSA
Just an update that in line with the re-organization and new site for python social auth (https://github.com/python-social-auth) I have made a new repository https://github.com/DonaldMcC/social-app-web2py with updated import statements etc. The plug-in has been tested with google, facebook, twitter and microsoft providers and demo is available at http://www.netdecisionmaking.com/socialappweb2py/default/index It's still entirely based on https://github.com/bnmnetp/w2p-social-auth but just rolled forward in line with psa changes and far from fully tested. On Sunday, November 6, 2016 at 11:38:45 PM UTC, Donald McClymont wrote: > > Not a great deal from me - it is still generally working fine with latest > version of psas on www.netdecisionmaking.com - this is really a hobby > project to demo a different approach to running the world or any part of > it. Only change I have made recently was to swap-out mozilla persona and > replace with google+ as Mozilla are turning off persona at the end of > November. That does however give me an issue that google+ authentication > works but doesn't populate the users email which obviously then means users > logging in this way will not get mails. I need to look at how to add > additional steps to query this after authentication at some point. > > Regards > Donald > > > > On Saturday, November 5, 2016 at 3:12:37 PM UTC, mweissen wrote: >> >> It is a very interesting project. Are there any news? >> >> Am Freitag, 24. Juni 2016 00:45:51 UTC+2 schrieb Donald McClymont: >>> >>> Just a further note that following some further updating I can login via >>> Facebook, Twitter, Google (using Mozilla Persona) and Microsoft accounts. >>> There is a test site at https://www.netdecisionmaking.com/w2ppsatest >>> if anyone wants to take a look without setting up themselves. I am not >>> really planning to do much more with this unless there are issues or >>> suggestions on what needs done next. >>> >>> Regards >>> Donald >>> >>> On Friday, June 10, 2016 at 9:49:05 PM UTC+1, Donald McClymont wrote: I have now forked and pruned w2p-social-auth at the following: https://github.com/DonaldMcC/w2p-social-auth basically only two changes of substance: 1 It now uses appconfig to store the keys in so you will need to be on a fairly recent web2py if you want to use this approach - alternatively just put the keys directly into db.py but this obviously isn't a best practice with github for sharing code. 2 I have removed the version of python social auth - I think 0.1.24 which was included in previous file which means a lot less code - as far as I can tell this was unmodified however it was not best if the plugin was importing from their and internal imports within PSA were from the installed version of that I had installed as a python package. Having done the above - I have successfully completed a basic login with the revised plugin and PSA 0.2.19 which is the latest version use Mozilla Persona as the provider - I will need to move it onto an actual site rather than localhost to test a few other providers but that will be next week at the earliest and I still have a very limited knowledge of Auth, PSA or the actual code in the plug-in - so it would be good if people that do could perhaps chip-in with suggestions on where this should be heading and how it should be properly tested that would be appreciated. Donald On Monday, June 6, 2016 at 10:43:18 PM UTC+1, Donald McClymont wrote: > > Sounds good - possibly worth trying to contact someone on the psa team > as well. I think we need to decide whether an updated plug-in is the > best > way to go or whether this should be a core part of either PSA or web2py. > The plug-in may be the quickest way forward but it might well be better > to > go another route as it reduces the risk of being back in the same > situation > we have now where changes in PSA mean the plug-in doesn't work with > latest > versions. > > There was some previous dialogue on wihether python social auth or > authomatic was the better approach and that did seem to come down in > favour > of PSA because authomatic was no longer being maintained. > > Donald > > On Monday, June 6, 2016 at 12:30:29 AM UTC+1, Joe Barnhart wrote: >> >> Well I don't know about OAuth or auth-social, but I know web2py auth >> and I know python pretty well. I'll do a little reading on the whole >> concept of social-auth and see if I can dig up more resources, like >> maybe >> the author of w2p-social-auth. If worse comes to worst, I can get some >> help from Massimo. I think a social auth plug-in that works really well >> would be not only useful, but essential to web2py at this poin
[web2py] Re: How can i create radio buttons in web2py? And how can i link it with database?
Please read the book sections that Dave S pointed you towards so you can create your radio buttons. We do not give you fish in this forum, we teach you how to fish and those book pages will teach you how to create radio buttons. -- 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: Invalid SQLFORM submit generates ticket instead of redirecting back to form with errors
On Wednesday, January 11, 2017 at 1:16:02 PM UTC-5, Rahul Priyadarsi wrote: > > Thanks for the reply @Antony. > When I posted this question on this Forum, i did not see it appear so I > thought something must be wrong with google groups itself. Hence I posted > on stackoverflow. > No problem. If this was your first post, it would have to be approved before appearing. 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] Self-hosted web analytics solutions for Web2py
I think you can have it with : response.session_id So you will have to add a column to the model and set default=response.session_id... Richard On Tue, Jan 10, 2017 at 7:23 PM, Joe wrote: > I worked it out. It's great! Working fine! Thanks again. "BTW: what is the > best way to include a unique session id for each visit in the > 'usage_statistics' > table?" > > On Wednesday, January 11, 2017 at 2:09:24 AM UTC+8, Richard wrote: >> >> I guess you need to create the table... For some reason the web2py-slice >> site does block in fortigate so, I am not sure of the code... I guess there >> is migrate set to False or something or you set migrations to False in your >> connection string. >> >> Richard >> >> On Sun, Jan 8, 2017 at 8:21 AM, Joe wrote: >> >>> Thanks for the link Richard, >>> >>> I just copied everything and tried it but I am getting this error: >>> OperationalError: no such table: usage_statistics >>> >>> I think I am missing a step. >>> >>> Can you please advise. >>> >>> Thanks. >>> >>> Cheers, >>> >>> Joe >>> >>> >>> >>> >>> >>> On Friday, January 6, 2017 at 11:12:36 PM UTC+8, Richard wrote: You can look on the side of piwik : https://piwik.org/ If you only want to log your users activity and don't need that much of analytic you can have look at this slice : http://www.web2pyslices.com/slice/show/1618/basic-usage-stat istics-log-what-your-users-do But it has a drawback which is that it makes an insert each time users make request... Plus you don't have any analytics, graph, you have to forge your own query to trend your data. Here there was discussion about improving this contrib by making it less database intensive : https://groups.google.com/d/ msg/web2py/659_7_hDiks/947KRwtQDssJ good luck Richard On Fri, Jan 6, 2017 at 8:12 AM, Joe wrote: > I am interested in using a self-hosted web analytics solutions on > Pythonanywhere for my Web2py apps. > I asked this question on the Pythonanywhere forum, they suggested to > ask here. > Can anyone suggest the best solution for this and let me know the > easiest way to install it on the server? > Thanks. > Cheers, > Joe > > -- > 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+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. > -- 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: Store value in input field in a table
Can we see the entire controller and view where you're trying 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: Invalid SQLFORM submit generates ticket instead of redirecting back to form with errors
Thanks for the reply @Antony. When I posted this question on this Forum, i did not see it appear so I thought something must be wrong with google groups itself. Hence I posted on stackoverflow. On Wednesday, January 11, 2017 at 5:35:18 AM UTC+5:30, Anthony wrote: > > FYI, already answered on SO: http://stackoverflow.com/a/41554743/440323 > > Anthony > > On Tuesday, January 10, 2017 at 6:07:17 PM UTC-5, Rahul Priyadarsi wrote: >> >> Here is my db.py: >> >> db.define_table('antenna_details', >> Field('antenna_name',required=True), >> Field('model_name',required=True), >> Field('project_name',required=True), >> Field('frequency_band',required=True), >> Field('polarization',required=True), >> Field('aperture_size',required=True), >> Field('fixer_availability',required=True), >> Field('weight',required=True), >> Field('material',required=True), >> >> Field('email_id',required=True,unique=True,requires=[IS_NOT_IN_DB]), >> Field('subject',type='text',required=True), >> Field('attached',type='upload', label=""" >> Antenna/feed Geometry >> Electrical specification >> Attach Simulated data in predicted form >> """) >> ) >> >> db.antenna_details.email_id.requires=[IS_EMAIL(),IS_NOT_EMPTY()] >> db.antenna_details.attached.requires=IS_NOT_EMPTY() >> db.antenna_details.subject.rquires=IS_NOT_EMPTY() >> db.antenna_details.material.requires=IS_NOT_EMPTY() >> db.antenna_details.weight.requires=IS_NOT_EMPTY() >> db.antenna_details.fixer_availability.requires=IS_NOT_EMPTY() >> db.antenna_details.aperture_size.requires=IS_NOT_EMPTY() >> db.antenna_details.polarization.requires=IS_NOT_EMPTY() >> db.antenna_details.frequency_band.requires=IS_NOT_EMPTY() >> db.antenna_details.project_name.requires=IS_NOT_EMPTY() >> db.antenna_details.model_name.requires=IS_NOT_EMPTY() >> >> >> And I am using SQLFORM to create a form for it: >> >> def index(): >> """ >> example action using the internationalization operator T and flash >> rendered by views/default/index.html or views/generic.html >> >> if you need a simple wiki simply replace the two lines below with: >> return auth.wiki() >> """ >> # response.flash = T("Hello World") >> # return dict(message=T('Welcome to web2py!')) >> >> form = SQLFORM(db.antenna_details).process() >> >> if form.process().accepted: >> response.flash = 'your data is posted' >> >> return dict(form=form) >> >> My problem is that when I submit a form with duplicate email id(that >> already exists in db), instead of redirecting back to form and showing the >> error, it generates a ticket like this: >> >> column email_id is not unique >> >> While if I submit with empty fields, it simply redirects to the form and >> shows errors besides the respective input tags in red. >> Why is it happening like this for email_id field only? And how do I >> disable this to show error messages in form itself? >> > -- 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: ajax and 403 forbidden issue..
The web2py ajax does not have the ".then" method or errror:function... like the regular $.ajax Do i have to use $.ajax instead? Seems that the error function is missing from web2py ajax. Why is it not implemented ? Regards António 2017-01-11 15:21 GMT+00:00 António Ramos : > Hello i use the web2py ajax function to call an action that needs > auth.requires_signature() > INPUT(_onclick="ajax('"+url+"',[],':eval')" > > the users see a popup that i inject in the response because of the eval > > However if i have admin open and do a query, when i go back to that user > page and click again on the input the browser gets in the console > Failed to load resource: the server responded with a status of 403 > (Forbidden) > comming from default/user/not_authorized > This seems to be related to the query via admin and ssl. That is not a big > problem but... > > How can i detect this to have another popup to warn the user that the > click was not succedded ? > > > -- 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] How to use a list:string as string
What I want to do: I have a Field("aa", "list:string") and I know that the internal representation is e.g. "|x|y|z|u|v|". Now I want to find all rows with aa[0]=='x' and aa[1]=='y' and aa[2]=='z' and aa[3]=='u' (that is a simplified example). I have tried db.mytable.aa.type = 'text' res = db(db.mytable.aa.like('|x|y|z|u|%').select() Some more details: My program should find all records with '|x|y|z|u|'. If there are no records the second try should look for '|x|y|z|'. Without any result the next step should be to look for '|x|y|' and so on. It works as expected. My question: is this solution efficient? Is there any better solution? Regards, Martin -- 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] ajax and 403 forbidden issue..
Hello i use the web2py ajax function to call an action that needs auth.requires_signature() INPUT(_onclick="ajax('"+url+"',[],':eval')" the users see a popup that i inject in the response because of the eval However if i have admin open and do a query, when i go back to that user page and click again on the input the browser gets in the console Failed to load resource: the server responded with a status of 403 (Forbidden) comming from default/user/not_authorized This seems to be related to the query via admin and ssl. That is not a big problem but... How can i detect this to have another popup to warn the user that the click was not succedded ? -- 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: Foreign key constraint failed
Hello Anthony, my eintrag_erstellen is a html view: -- {{extend 'layout.html'}} {{block header}} {{end}} Erstelle einen neuen Beitrag über das Thema {{=category.name.title()}} {{=form}} -- I gain access this way: 1. I click this button in another view: -- Neuer Eintrag -- which leads me to this: -- def erstellen(): rows = db(db.category).select() form = SQLFORM(db.eintrag).process(next='eintrag_betrachten/[id]') return locals() -- and this view: -- {{extend 'layout.html'}} {{block header}} {{end}} Profil | Ausloggen | Mitgliedschaft beenden Eintrag erstellen {{for category in rows:}} {{=A(category.name.title(),_class='btn',_href=URL('eintrag_erstellen',args=category.name))}} {{pass}} -- There all my categories got listed in a single button. When I click on one of them, I gain acces to my eintrag_erstellen view -- 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.