[web2py] How do I make this button redirect to a controller function when enter is pressed?
document.getElementById("search") .addEventListener("keyup", function(event) { event.preventDefault(); if (event.keyCode == 13) { document.getElementById("searchbutton").click(); } }); I see that neither enter works nor search.text is correct at this context. How should I correct it? -- 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: Login page - Menu bar does not work
I would really appreciate if you could be more specific? On Wednesday, September 21, 2016 at 6:18:11 PM UTC-5, SR wrote: > > When I am in the Login page, the menu items does not work. > Any idea why it is not working? > 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.
[web2py] Re: Is there a way to execute functions within functions without leaving the parent function?
New recent nuance on this. Is there any way to avoid the conditional phrasing in function add_new_anything below? The problem is there is a user prompt in select_country_manually function that is called called from add_new_anything. The _href in select_country_manually requires a controller to go to in order to capture the correct country and then exit. Then I have to build conditionals to let the script pickup where it left off in add_new_anything. Is this the only way to write this? It is anticipated that select_country_manually will be called from many different functions. thanks Alex Glaros def add_new_anything(): populating_address_type = str(request.get_vars.populating_address_type) session.populating_address_type = populating_address_type session.countryID = request.get_vars.countryID if not session.countryID: redirect(URL('default', 'select_country_manually', vars = dict(controller_to_return_to = 'add_new_anything'))) response.title = session.countryID return locals() @auth.requires_login() def select_country_manually(): controller_to_return_to = request.get_vars.controller_to_return_to session.countryID = None session.country_name = None db.Country.country_name.represent = lambda v, r: A(v, _href = URL( 'default', controller_to_return_to, vars = dict(countryID = r.id))) grid = SQLFORM.grid(db.Country, editable = False, deletable = False, create = False, details = False, maxtextlength = {'Country.country_name': '140'}, paginate = 300, fields = [db.Country.id, db.Country.country_name, db .Country.country_code]) response.title = T('Select country') return locals() -- 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: Plugin providing a Location picker widget for geometry fields
Just for reference I have hacked about with this a bit at the following link: https://github.com/DonaldMcC/w2p_location_widget It now provides an example app with reverse geocoding, ability to pickup users location per html5 and a method of working with non-geospatial databases by moving the result to separate latitude and longitude - however some of that is not strictly plugin and would need a bit more incorporation. Doubtless there are better ways of doing this but as far as I can see what is there does work. Donald On Friday, August 15, 2014 at 4:52:57 AM UTC+1, Leonel Câmara wrote: > > In 12 hours or so I'm going on a week long vacation, before I go, I > thought this could be useful to some people here, even if just as an > example, now that the DAL supports geo stuff. > > This small plugin provides a location picker and a validator for geometry > (NOT geography) fields that actually represent real points on the map. > > The usage is quite simple and here's an example: > > from plugin_location_picker import location_widget, IS_GEOLOCATION > > db.define_table('point', > Field('name'), > Field('coord', 'geometry()', requires=IS_GEOLOCATION(), > widget=location_widget()) > ) > > Here's a more complex example that makes the map start in the center of > Lisbon (Everyone should use this): > > from plugin_location_picker import location_widget, IS_GEOLOCATION > > db.define_table('point', > Field('name'), > Field('coord', 'geometry()', requires=IS_GEOLOCATION(), > widget=location_widget(map_options={'center': {'lat': 38.725275, 'lng': > -9.150028}}, marker_options={'position': {'lat': 38.725275, 'lng': > -9.150028}})) > ) > > Finally, go to appadmin and add points to your point table, verify that > you now have an awesome widget (well the bootstrap 3 classes probably need > improvement so the appearance may be odd). > > Also, remember to make sure your backend is one of those supported by the > geoDAL sqlite/spatialite postgres/postgis or mssql. I actually only tested > this with postgresql and postgis so results may vary. > > Respect the BEER-WARE license please. > -- 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: Password Recovery Not Sending (lazyT object being passed to GAE?)
The same error when I try to register an user: Unable to send email. Mail.send failure:coercing to Unicode: need string or buffer, lazyT found I don't know what to do El domingo, 31 de julio de 2016, 8:36:02 (UTC+2), Massimo Di Pierro escribió: > > OK. will check this today. > > On Friday, 29 July 2016 15:40:26 UTC-5, webm...@trytha.com > wrote: >> >> Nope, same error in: 2.14.6-stable+timestamp.2016.05.10.00.21.47 (the >> source code off the web2py site). >> >> If you want me to try a nightly or something, let me know. >> >> The only semi-unique thing about my app is that I allow usernames for >> login as well. Here is my default/user(): >> >> def user(): >> >> db.auth_user.first_name.writable = False >> db.auth_user.last_name.writable = False >> >> # NOTE: This is an addition I found that enables using usernames (default >> is email as login). >> if 'login' in request.args: >> db.auth_user.username.label = T('Username or Email') >> auth.settings.login_userfield = 'username' >> if request.vars.username and not IS_EMAIL()(request.vars.username)[1]: >> auth.settings.login_userfield = 'email' >> request.vars.email= request.vars.username >> request.post_vars.email = request.vars.email >> request.vars.username = None >> request.post_vars.username= None >> >> >> >> return dict(form = auth()) >> >> Everything was working fine in 2.12.2, but I can't say for certain it was >> working in my 2.13 deployment. >> >> >> >> >> On Friday, July 29, 2016 at 6:26:11 AM UTC-7, Massimo Di Pierro wrote: >>> >>> This may have been fixed already. Can you upgrade and try it? >>> >>> On Friday, 29 July 2016 00:49:14 UTC-5, webm...@trytha.com wrote: I just uploaded an updated version of web2py to my server, replacing a much older version (likely 2.12.2), and now it won't send password recovery emails. The error in the logs is: Mail.send failure:coercing to Unicode: need string or buffer, lazyT found This suggests to me that somehow a string is not properly being passed. I gather that lazyT has something to do with the built-in translation capabilities of web2py? Probably don't need to be translating email addresses (though I guess it could be trying to translate the recovery message). Either way, GAE wants nothing to do with it. How can I fix 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: SQLFORM.grid w/ selectable generates multiple requests
On Thursday, September 22, 2016 at 2:14:41 PM UTC-4, Anthony wrote: > > On Thursday, September 22, 2016 at 6:45:55 AM UTC-4, Scott Hunter wrote: >> >> Because I don't need it. The original call tells me enough to make the >> modifications I need to do, and then proceeds to build an up-to-date grid, >> which becomes wasted effort because I'm getting a redirect re-build the >> page I just built. >> > > The grid code first retrieves the records and then calls the selectable > callback (which it must do, as the record ids are passed to the callback), > so if the callback makes any modifications to the records, the resulting > grid will *not* contain up-to-date data unless the grid is called again > (hence the redirect). I think the idea is to ensure it works in all cases, > though I agree it could be made more efficient in some cases. > > For now, a workaround is to check for request.post_vars.records, and if > present, run whatever code you need to, and then delete > request.post_vars.records and request.post_vars.formname before creating > the grid (this will prevent the form from being accepted and therefore skip > the redirect). You could abstract this into a wrapper around the grid. > Note, with the above method, you would be foregoing the web2py form processing functionality, which among other things protects against CSRF. If you want to allow the grid to handle the form processing and callback as usual but still short circuit the redirect, you could do something like this: def mygrid(*args, **kwargs): try: return SQLFORM.grid(*args, **kwargs) except HTTP as e: if e.status == 303 and 'records' in request.post_vars: del request.post_vars.records del request.post_vars._formname return SQLFORM.grid(*args, **kwargs) def myfunc(): return dict(grid=mygrid(..., selectable=mycallback)) 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: Pass variable from JavaScript function to controller: Using JSQueryBuilder
"result" is a Javascript variable, so it does not exist in the Python context in which the URL() function is evaluated. Instead, you must add that part of the URL via Javascript: ajax('{{=URL('default', 'showfilters')}}' + '?result=' + result, [], ':eval' ); Anthony On Thursday, September 22, 2016 at 8:49:47 AM UTC-4, Madhavi wrote: > > Hi, > > > > I am trying to use JavaScript Query Builder plugin (querybuilder.js.org) > with web2py. The plugin is installed successfully and I can see the > querybuilder object in my view. I want to finally pass the string > containing the filters selected from the view to another controller > function for further processing. The code I am using on the view is below: > > > > Get rules > > > > function myFunction();{ > > var result = > JSON.stringify($('#builder-basic').queryBuilder('getRules'), null, 2); > > ajax('{{=URL('default', 'showfilters', > vars=dict(result=result))}}', [], ':eval'); > > } > > > > > > I want to pass ‘result’ variable to ‘showfilters’ controller function and > call ‘showfilters’ view on clicking on ‘Get rules’ button. But the above > code doesn’t work and gives this error: > > * name 'result' is not defined* > > I understand this could be because 'result' variable is not defined in my > controller function corresponding to this view. What is the correct way to > pass the value of a variable declared through Java Script to a controller > function in web2py? > > Please help me here – I am novice to both web2py and Java Script and have > been struggling with this for quite some time. I would prefer to pass the > variable result through dictionary and not as an argument, as it will > contain spaces and special characters which I want to preserve in the > string. > > Thanks, > > Madhavi > -- 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: SQLFORM.grid w/ selectable generates multiple requests
On Thursday, September 22, 2016 at 6:45:55 AM UTC-4, Scott Hunter wrote: > > Because I don't need it. The original call tells me enough to make the > modifications I need to do, and then proceeds to build an up-to-date grid, > which becomes wasted effort because I'm getting a redirect re-build the > page I just built. > The grid code first retrieves the records and then calls the selectable callback (which it must do, as the record ids are passed to the callback), so if the callback makes any modifications to the records, the resulting grid will *not* contain up-to-date data unless the grid is called again (hence the redirect). I think the idea is to ensure it works in all cases, though I agree it could be made more efficient in some cases. For now, a workaround is to check for request.post_vars.records, and if present, run whatever code you need to, and then delete request.post_vars.records and request.post_vars.formname before creating the grid (this will prevent the form from being accepted and therefore skip the redirect). You could abstract this into a wrapper around the grid. 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] Pass variable from JavaScript function to controller: Using JSQueryBuilder
Hi, I am trying to use JavaScript Query Builder plugin (querybuilder.js.org) with web2py. The plugin is installed successfully and I can see the querybuilder object in my view. I want to finally pass the string containing the filters selected from the view to another controller function for further processing. The code I am using on the view is below: Get rules function myFunction();{ var result = JSON.stringify($('#builder-basic').queryBuilder('getRules'), null, 2); ajax('{{=URL('default', 'showfilters', vars=dict(result=result))}}', [], ':eval'); } I want to pass ‘result’ variable to ‘showfilters’ controller function and call ‘showfilters’ view on clicking on ‘Get rules’ button. But the above code doesn’t work and gives this error: * name 'result' is not defined* I understand this could be because 'result' variable is not defined in my controller function corresponding to this view. What is the correct way to pass the value of a variable declared through Java Script to a controller function in web2py? Please help me here – I am novice to both web2py and Java Script and have been struggling with this for quite some time. I would prefer to pass the variable result through dictionary and not as an argument, as it will contain spaces and special characters which I want to preserve in the string. Thanks, Madhavi -- 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: SQLFORM.grid w/ selectable generates multiple requests
Because I don't need it. The original call tells me enough to make the modifications I need to do, and then proceeds to build an up-to-date grid, which becomes wasted effort because I'm getting a redirect re-build the page I just built. - Scott On Wednesday, September 21, 2016 at 3:19:15 PM UTC-4, Anthony wrote: > > On Wednesday, September 21, 2016 at 1:16:29 PM UTC-4, Scott Hunter wrote: >> >> I think I understand; seems like something that should be documented, as >> well as able to be disabled. >> > > Is it causing a problem for you? Why do you need to disable the redirect? > > 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] Login page - Menu bar does not work
The last time it happens to me (menu did not open on click), I had an error in my javascript… Look at the navigator javascript console… On Thu, Sep 22, 2016 at 1:18 AM SR wrote: > When I am in the Login page, the menu items does not work. > Any idea why it is not working? > 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. > -- 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.