[web2py] last_run_time as argument for a scheduled function
Hi, a question about the scheduler: The scheduler calls a function f() 12 times per hour. db.scheduler_task knows the last_run_time and next_run_time. I want to call the function f with these two values as arguments. Is there a simple way? Regards, Martin --
Re: [web2py] Storing Python code in db?
http://docs.python.org/2/library/pickle.html http://python.about.com/od/pythonstandardlibrary/a/pickle_intro.htm --
[web2py] Re: last_run_time as argument for a scheduled function
absolutely not clear what you want, but i guess a simple db(db.scheduler_task.function_name = 'yourfunction').select(db.scheduler_task.next_run_time, db.scheduler_task.last_run_time) will fetch the values to use in that function call you need. On Saturday, January 19, 2013 9:04:34 AM UTC+1, mweissen wrote: Hi, a question about the scheduler: The scheduler calls a function f() 12 times per hour. db.scheduler_task knows the last_run_time and next_run_time. I want to call the function f with these two values as arguments. Is there a simple way? Regards, Martin --
Re: [web2py] If I upload a file manually does it check the validators?
On Sat, Jan 19, 2013 at 12:12 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: filename=(fileApp.filename.repl**ace(' ', '') if fileApp else '') Interesting, I have tried it before but even it does not work... the error appears everytime that I enable the validation during the insert... the code that Bruno posted above def my_upload(): import re #print request.vars.pic.filename fileApp=request.vars.pic #print dir(fileApp) #filename=fileApp.filename.replace(' ', '') filename=(fileApp.filename.replace(' ', '') if fileApp else '') #filename='test.jpg' result='' http_host='' #Prevent special caracters in the file name expression='[*+~$^#@!;:,|]' regex = re.compile(expression) if regex.search(filename): result=Special caracters NO!!! Nothing to do... return response.json('div class=error_wrapperdiv id=title__error class=error style=display: inline-block;'+result+'/div/div') aux=db.files.file_upload.store(fileApp, filename) #db.files.insert(file_upload=aux,title=filename) *# USING THIS LINE IT WORKS * *db.files.validate_and_insert(file_upload=db.files.file_upload.store(fileApp, filename),title=filename)* # *THIS LINE CAUSES THE ERROR * if request.env.http_x_forwarded_host: http_host = request.env.http_x_forwarded_host.split(':',1)[0] else: http_host = request.env.http_host last = db().select(db.files.ALL)[-1] result=T('Successfuly! Here the link: ') result+=a href=http:// +http_host+'/'+request.application+'/'+request.controller+'/download/'+last.file_upload+Download/a return response.json('div class=alert alert-success'\ +result+\ '/div') 186.214.187.119.2013-01-19.12-53-48.0336b24c-763e-4a83-bff2-50de3905d280 type 'exceptions.AttributeError' 'NoneType' object has no attribute 'name' Versão web2py™ (2, 3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable') Python Python 2.7.3: /usr/local/bin/uwsgi Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Traceback (most recent call last): File /home/titogarrido/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/titogarrido/web2py/applications/cms/controllers/default.py https://titogarrido.pythonanywhere.com/admin/default/edit/cms/controllers/default.py, line 118, in module File /home/titogarrido/web2py/gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/titogarrido/web2py/applications/cms/controllers/default.py https://titogarrido.pythonanywhere.com/admin/default/edit/cms/controllers/default.py, line 100, in my_upload aux=db.files.file_upload.store(fileApp, filename) File /home/titogarrido/web2py/gluon/dal.py, line 8601, in store filename = file.name AttributeError: 'NoneType' object has no attribute 'name' -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ --
Re: [web2py] Re: last_run_time as argument for a scheduled function
ok, thank you. 2013/1/19 Niphlod niph...@gmail.com absolutely not clear what you want, but i guess a simple db(db.scheduler_task.function_name = 'yourfunction').select(db.scheduler_task.next_run_time, db.scheduler_task.last_run_time) will fetch the values to use in that function call you need. On Saturday, January 19, 2013 9:04:34 AM UTC+1, mweissen wrote: Hi, a question about the scheduler: The scheduler calls a function f() 12 times per hour. db.scheduler_task knows the last_run_time and next_run_time. I want to call the function f with these two values as arguments. Is there a simple way? Regards, Martin --
Re: [web2py] If I upload a file manually does it check the validators?
aux=db.files.file_upload.store(fileApp, filename) #db.files.insert(file_upload=aux,title=filename) *# USING THIS LINE IT WORKS * *db.files.validate_and_insert(file_upload=db.files.file_upload.store(fileApp, filename),title=filename)* # *THIS LINE CAUSES THE ERROR* But the traceback shows the error in the first line above (i.e., aux=...), so how can the second line work if the error occurs before it? Note, the first line runs unconditionally, even when there is no fileApp, so it should (and apparently does) raise an exception when there is no upload. Anthony --
[web2py] Re: Logging in with applications.
Where do you read that comment? login_bare does login the user and returns the user record. On Saturday, 19 January 2013 00:31:00 UTC-6, encompass wrote: The last link was the one I was looking at first. Before this post. But login_bare returns user if the user exists and the password is valid, else it returns False. username is the email if the auth_user table does not have a username field. doesn't sound like I logged in a user. It just returns the user and returns false. But I will give it a try. BR, Jason Brower On Friday, January 18, 2013 11:39:35 PM UTC+2, Alan Etkin wrote: My current app runs with only JSON calls is there a way to make the login occure with JSON? Did you check this? http://www.web2py.com/books/default/chapter/29/10#Services-and-Authentication http://www.web2py.com/books/default/chapter/29/09#Access-Control-and-Basic-Authentication http://www.web2py.com/books/default/chapter/29/09#Manual-Authentication --
Re: [web2py] If I upload a file manually does it check the validators?
Now that you show more of your code, things are more clear ... fileApp=request.vars.pic filename=fileApp.filename.replace(' ', '') ... for you fileApp is None, while you expect a cgi.FieldStorage object. I do not know why that is. It would be pic is the fron var name. It could be the upload is not being submitted. It could be the form is not a multipart form. I cannot say. You see to be bypassing the SQLFORM. On Saturday, 19 January 2013 06:57:52 UTC-6, Tito Garrido wrote: On Sat, Jan 19, 2013 at 12:12 AM, Massimo Di Pierro massimo@gmail.comjavascript: wrote: filename=(fileApp.filename.repl**ace(' ', '') if fileApp else '') Interesting, I have tried it before but even it does not work... the error appears everytime that I enable the validation during the insert... the code that Bruno posted above def my_upload(): import re #print request.vars.pic.filename fileApp=request.vars.pic #print dir(fileApp) #filename=fileApp.filename.replace(' ', '') filename=(fileApp.filename.replace(' ', '') if fileApp else '') #filename='test.jpg' result='' http_host='' #Prevent special caracters in the file name expression='[*+~$^#@!;:,|]' regex = re.compile(expression) if regex.search(filename): result=Special caracters NO!!! Nothing to do... return response.json('div class=error_wrapperdiv id=title__error class=error style=display: inline-block;'+result+'/div/div') aux=db.files.file_upload.store(fileApp, filename) #db.files.insert(file_upload=aux,title=filename) *# USING THIS LINE IT WORKS * *db.files.validate_and_insert(file_upload=db.files.file_upload.store(fileApp, filename),title=filename)* # *THIS LINE CAUSES THE ERROR * if request.env.http_x_forwarded_host: http_host = request.env.http_x_forwarded_host.split(':',1)[0] else: http_host = request.env.http_host last = db().select(db.files.ALL)[-1] result=T('Successfuly! Here the link: ') result+=a href=http://+http_host+'/'+request.application+'/'+request.controller+'/download/'+last.file_upload+Download/a return response.json('div class=alert alert-success'\ +result+\ '/div') 186.214.187.119.2013-01-19.12-53-48.0336b24c-763e-4a83-bff2-50de3905d280 type 'exceptions.AttributeError' 'NoneType' object has no attribute 'name' Versão web2py™ (2, 3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable') Python Python 2.7.3: /usr/local/bin/uwsgi Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Traceback (most recent call last): File /home/titogarrido/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/titogarrido/web2py/applications/cms/controllers/default.py https://titogarrido.pythonanywhere.com/admin/default/edit/cms/controllers/default.py, line 118, in module File /home/titogarrido/web2py/gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/titogarrido/web2py/applications/cms/controllers/default.py https://titogarrido.pythonanywhere.com/admin/default/edit/cms/controllers/default.py, line 100, in my_upload aux=db.files.file_upload.store(fileApp, filename) File /home/titogarrido/web2py/gluon/dal.py, line 8601, in store filename = file.name AttributeError: 'NoneType' object has no attribute 'name' -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ --
[web2py] compute field doesn't work on update
Other users have the same problem and, sorry but I can't find my solution; i tried with readable=true and writable=true, to update all the field interested in the compute function, to comment the line in DAL.py, but nothing. I have this table: db.define_table('magazzino', Field('id_tipo', 'integer',default=0), Field('p_p','double', default=0.0), Field('pp_tot','double', writable=True, readable=True, compute=lambda r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1), ) If I edit a row with a FORM the compute field works but if I edit it in a function with ajax don't... def modArtPrice(): newPp = 100 articolo = db.magazzino[request.vars.id] articolo.id_tipo=articolo.id_tipo articolo.p_p=newPp articolo.update_record() what's wrong? s. --
Re: [web2py] If I upload a file manually does it check the validators?
Also I am using RESIZE validator from imageutils.py Not sure why it happens... anyway I was trying to use http://www.web2pyslices.com/slice/show/1576/html5-file-uploads-with-jquerywith RESIZE... I could use it uisng THUMB, but the RESIZE validator doesn't work for the main image... On Sat, Jan 19, 2013 at 12:25 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Now that you show more of your code, things are more clear ... fileApp=request.vars.pic filename=fileApp.filename.**replace(' ', '') ... for you fileApp is None, while you expect a cgi.FieldStorage object. I do not know why that is. It would be pic is the fron var name. It could be the upload is not being submitted. It could be the form is not a multipart form. I cannot say. You see to be bypassing the SQLFORM. On Saturday, 19 January 2013 06:57:52 UTC-6, Tito Garrido wrote: On Sat, Jan 19, 2013 at 12:12 AM, Massimo Di Pierro massimo@gmail.com wrote: filename=(fileApp.filename.rep**l**ace(' ', '') if fileApp else '') Interesting, I have tried it before but even it does not work... the error appears everytime that I enable the validation during the insert... the code that Bruno posted above def my_upload(): import re #print request.vars.pic.filename fileApp=request.vars.pic #print dir(fileApp) #filename=fileApp.filename.**replace(' ', '') filename=(fileApp.filename.**replace(' ', '') if fileApp else '') #filename='test.jpg' result='' http_host='' #Prevent special caracters in the file name expression='[*+~$^#@!;:,|]' regex = re.compile(expression) if regex.search(filename): result=Special caracters NO!!! Nothing to do... return response.json('div class=error_wrapperdiv id=title__error class=error style=display: inline-block;'+result+'/ **div/div') aux=db.files.file_upload.**store(fileApp, filename) #db.files.insert(file_upload=**aux,title=filename) *# USING THIS LINE IT WORKS * *db.files.validate_and_insert(file_upload=db.files.file_upload.store(fileApp, filename),title=filename)* # *THIS LINE CAUSES THE ERROR * if request.env.http_x_forwarded_**host: http_host = request.env.http_x_forwarded_**host.split(':',1)[0] else: http_host = request.env.http_host last = db().select(db.files.ALL)[-1] result=T('Successfuly! Here the link: ') result+=a href=http://+http_host+'/'+**request.application+'/'+** request.controller+'/download/**'+last.file_upload+Download**/a return response.json('div class=alert alert-success'\ +result+\ '/div') 186.214.187.119.2013-01-19.12-**53-48.0336b24c-763e-4a83-bff2-** 50de3905d280 type 'exceptions.AttributeError' 'NoneType' object has no attribute 'name' Versão web2py™ (2, 3, 2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable') Python Python 2.7.3: /usr/local/bin/uwsgi Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Traceback (most recent call last): File /home/titogarrido/web2py/**gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/titogarrido/web2py/**applications/cms/controllers/**default.py https://titogarrido.pythonanywhere.com/admin/default/edit/cms/controllers/default.py, line 118, in module File /home/titogarrido/web2py/**gluon/globals.py, line 193, in lambda self._caller = lambda f: f() File /home/titogarrido/web2py/**applications/cms/controllers/**default.py https://titogarrido.pythonanywhere.com/admin/default/edit/cms/controllers/default.py, line 100, in my_upload aux=db.files.file_upload.store**(fileApp, filename) File /home/titogarrido/web2py/**gluon/dal.py, line 8601, in store filename = file.name AttributeError: 'NoneType' object has no attribute 'name' -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ --
[web2py] Re: compute field doesn't work on update
Works for me: db =DAL() db.define_table('magazzino', ... Field('id_tipo', 'integer',default=0), ... Field('p_p','double', default=0.0), ... Field('pp_tot','double', writable=True, readable=True, compute=lambda r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1), ... ) Table magazzino (id,id_tipo,p_p,pp_tot) db.magazzino.insert(id_tipo=1,p_p=10) 1L print db.magazzino[1] Row {'pp_tot': -10.0, 'id_tipo': 1, 'id': 1, 'p_p': 10.0} newPp = 100 articolo = db.magazzino[1] articolo.id_tipo=articolo.id_tipo articolo.p_p=newPp articolo.update_record() Row {'pp_tot': -10.0, 'id_tipo': 1, 'id': 1, 'p_p': 100} what version do you have? Something else is wrong. By the way your code contains some hidden characters: articolo = db.magazzino\U+FEFF[request.vars.id] \U+FEFF Not sure if this is a problem or just a cut-and paste error. On Saturday, 19 January 2013 11:03:34 UTC-6, palomar wrote: Other users have the same problem and, sorry but I can't find my solution; i tried with readable=true and writable=true, to update all the field interested in the compute function, to comment the line in DAL.py, but nothing. I have this table: db.define_table('magazzino', Field('id_tipo', 'integer',default=0), Field('p_p','double', default=0.0), Field('pp_tot','double', writable=True, readable=True, compute=lambda r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1), ) If I edit a row with a FORM the compute field works but if I edit it in a function with ajax don't... def modArtPrice(): newPp = 100 articolo = db.magazzino[request.vars.id] articolo.id_tipo=articolo.id_tipo articolo.p_p=newPp articolo.update_record() what's wrong? s. --
[web2py] BEAUTIFY broken in trunk
Rows are not serialized by BEAUTIFY in trunk v4636 (since v4631 I believe). --
[web2py] Re: compute field doesn't work on update
I had the 2.1 and I've just updated to 2.3 (I hoped to solve the problem...) request.vars.id is the vars from the ajax call; it works, I'm sure, articolo.p_p is correctly updated Il giorno sabato 19 gennaio 2013 18:03:34 UTC+1, palomar ha scritto: Other users have the same problem and, sorry but I can't find my solution; i tried with readable=true and writable=true, to update all the field interested in the compute function, to comment the line in DAL.py, but nothing. I have this table: db.define_table('magazzino', Field('id_tipo', 'integer',default=0), Field('p_p','double', default=0.0), Field('pp_tot','double', writable=True, readable=True, compute=lambda r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1), ) If I edit a row with a FORM the compute field works but if I edit it in a function with ajax don't... def modArtPrice(): newPp = 100 articolo = db.magazzino[request.vars.id] articolo.id_tipo=articolo.id_tipo articolo.p_p=newPp articolo.update_record() what's wrong? s. --
[web2py] Re: BEAUTIFY broken in trunk
form = SQLFORM(db.auth_user) b = BEAUTIFY(form) b.xml() 'div/div' It seems it's a general problem with BEAUTIFY, not only with rows --
[web2py] Re: how to select current id record for record updat
Thank you very much for the help, Massimo. What this did was update all the records with the new invoice number. I re-read the chapter on DAL and see the info on the update_record. I still can't get it to select the database record I want and only update a record in memory, but I decided to change the logic and put the invoice in another place and it this works. Margaret --
Re: [web2py] Re: Insert on multiple tables with SQLFORM.grid
Thanks Anthoni, Great idea! That works for sure! Thanks! Il giorno 17/gen/2013 19:43, Anthony abasta...@gmail.com ha scritto: The create action of the grid results in a URL that ends with args /new/tablename, so you can do: if request.args and request.args[-2] == 'new': tablename = request.args[-1] [custom create code] Anthony On Thursday, January 17, 2013 11:32:08 AM UTC-5, AngeloC wrote: Hi guys, I'm trying to insert something into related tables with SQLFORM.grid. I want the user can see only one form with mixed fields for the various tables. Tables are related, so I have to insert a record contemporary on multiple tables. However I want to stick to SQLFORM.grid for the maximum extent. As far I can understand, there is no way to make it with the stock SQLFORM.grid, so I should opt for SQLFORM.factory. Is there an easy way to intercept the create (insertion) of SQLFORM.grid and replace it with an SQLFORM.factory? Thank you! -- Profile: http://it.linkedin.com/in/**compagnucciangelohttp://it.linkedin.com/in/compagnucciangelo -- --
[web2py] Re: BEAUTIFY broken in trunk
It works fine in 2.3.2, whether is rows or forms. --
[web2py] Re: BEAUTIFY broken in trunk
It works fine in 2.3.2, whether is rows or forms. I belive the problem was introduced by changing gluon/html.py here: http://code.google.com/p/web2py/source/detail?r=3fa5f8c16fe9437351e1e9ca2060471e9c73b16d --
[web2py] Re: Auth login with Firefox
This happens if cookies are disabled in a browser but you mention the welcome app works okay for login so that wouldn't be the cause. On Friday, 18 January 2013 16:59:53 UTC-8, villas wrote: Can't figure it out so I shall rebuild the app on top of the latest welcome. That seems to work ok. Thanks, D --
[web2py] unable to drop table
Hi, I am using stable web2py, with sqlite db and trying to drop a table. In the shell, I connect to the db, then In [6] : print db._uri sqlite://storage.sqlite In [7] : print db._dbname sqlite In [8] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] In [9] : db.sale.drop() In [10] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] In [11] : db.sale.drop() In [12] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] In [13] : db.commit() In [14] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] How do I get rid of the table sale but keep sales? The table persists after I end the web2py session. thanks, Margaret --
[web2py] Re: BEAUTIFY broken in trunk
That confirms my original suspicion, rev.4631, up to Massimo now. On Saturday, January 19, 2013 4:50:40 PM UTC-5, Alan Etkin wrote: It works fine in 2.3.2, whether is rows or forms. The problem was introduced by changing gluon/html.py here: http://code.google.com/p/web2py/source/detail?r=3fa5f8c16fe9437351e1e9ca2060471e9c73b16d --
[web2py] Re: unable to drop table
It works for me. web2py 2.3.2 src on windows. On Saturday, January 19, 2013 5:48:49 PM UTC-5, greaneym wrote: Hi, I am using stable web2py, with sqlite db and trying to drop a table. In the shell, I connect to the db, then In [6] : print db._uri sqlite://storage.sqlite In [7] : print db._dbname sqlite In [8] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] In [9] : db.sale.drop() In [10] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] In [11] : db.sale.drop() In [12] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] In [13] : db.commit() In [14] : print db.tables ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 'auth_cas', 'sale', 'sales'] How do I get rid of the table sale but keep sales? The table persists after I end the web2py session. thanks, Margaret --
Re: [web2py] unable to drop table
Is it the web shell? (if yes, its buggy) --
[web2py] Re: HOSTING FOR web2py ?
thanks bruno El viernes, 18 de enero de 2013 21:11:43 UTC-5, samuel bonilla escribió: I'm doing testing for my application in pythonanywhere.com, but I had some problems with paypal and I could not buy a domain. someone can recommend another hosting web2py to not only accept paypal ? thank you very much. --
[web2py] json validation
My app stores EDA information (cad programs for designing microchips) so storing cell attributes in a json object and taking advantage of json rpc would be beneficial. I am trying out Alex's new 'json' data type and with the serializer and IS_JSON() validator. Using the controller function below I've manage to create a json object of cell parameters (aka, attributes). In the function's comments is the output from the function but this output fails validation in http://jsonlint.com/ saying that RESULTS: Parse error on line 1: myobj={L: [ ^ Expecting '{', '[' CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page after being inserted into my Oracle DB. def json_parameters(param_names): takes an array of parameter names which are attributes to a design cell then looks up the default value and unit in the attributes table and returns an array of json dictionary objects to be inserted in the cell's parameters field as a json object if param_names = [L, len, R, INST, model, REF] myobj={ L: [ 0.001, nH ], len: [ 1, ??m ], R: [ 0.5, Ohm ], INST: [ i, TEXT ], model: [ m, TEXT ], REF: [ r, TEXT ] } params={} for a in param_names: # dbg.set_trace() rows = db(db.attribute.name.lower()==a.lower()).select(db.attribute.name, db.attribute.default_value, db.attribute.unit) row = rows[0] param = ('{}'.format(row.default_value), '{}'.format(row.unit)) params.update({'{}'.format(row.name):param}) return json(params) Any idea which is correct or how to fix it? Thank you, Bill --
[web2py] Re: Exposing validators as JSON?
+1 would a 'json:reference mytable' field type similar to 'list:reference mytable' or perhaps a format=lambda row: row.json() be possible? -Bill On Tuesday, January 15, 2013 6:14:40 PM UTC-6, Derek wrote: That would be cool, perhaps you could add a class to the fields and key off the classes. Or, have the validation function append error messages to a list and return that as json? On Tuesday, January 15, 2013 10:03:06 AM UTC-7, Alec Taylor wrote: How do I expose validators as JSON? I am not using web2py views in any capacity. Instead I am using AngularJS. So with web2py I am exposing my models RESTfully as JSON, and then consuming them with AngularJS. To reduce double-typing, how do I send field validators such as `IS_EMAIL` as JSON? # Model db.define_table( 'foo', Field('email', requires=IS_EMAIL()) ) # Controller @service.json def foo_form(): return dict(my_foo_form=crud.create(db.foo)) # Output I want { 'my_foo_form': { 'type': 'form', 'fields' { 'email', 'validator:IS_EMAIL'}, 'csrf': uid } } With this I can then write the equivalent functions in JavaScript and attach them to their corresponding fields. How do I do this with web2py? Thanks for all suggestions, Alec Taylor --
Re: [web2py] json validation
On 19 Jan 2013, at 4:21 PM, Bill Thayer bill.tha...@live.com wrote: My app stores EDA information (cad programs for designing microchips) so storing cell attributes in a json object and taking advantage of json rpc would be beneficial. I am trying out Alex's new 'json' data type and with the serializer and IS_JSON() validator. Using the controller function below I've manage to create a json object of cell parameters (aka, attributes). In the function's comments is the output from the function but this output fails validation in http://jsonlint.com/ saying that RESULTS: Parse error on line 1: myobj={L: [ ^ Expecting '{', '[' It looks like you're feeding jsonlint a string of the form myobj={some json object} instead of {some json object}. It's looking for a JSON object, which must begin with { or [, and it's finding 'm'. CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page after being inserted into my Oracle DB. def json_parameters(param_names): takes an array of parameter names which are attributes to a design cell then looks up the default value and unit in the attributes table and returns an array of json dictionary objects to be inserted in the cell's parameters field as a json object if param_names = [L, len, R, INST, model, REF] myobj={ L: [ 0.001, nH ], len: [ 1, ??m ], R: [ 0.5, Ohm ], INST: [ i, TEXT ], model: [ m, TEXT ], REF: [ r, TEXT ] } params={} for a in param_names: # dbg.set_trace() rows = db(db.attribute.name.lower()==a.lower()).select(db.attribute.name, db.attribute.default_value, db.attribute.unit) row = rows[0] param = ('{}'.format(row.default_value), '{}'.format(row.unit)) params.update({'{}'.format(row.name):param}) return json(params) Any idea which is correct or how to fix it? Thank you, Bill -- --
[web2py] Re: PowerFormWizard 0.1.4 - Bug Fixes and auto_validation (+ a new plugin for grids)
Hi Bruno, Forgive me if I missed your updates. The link below does not work today. Where can I find the latest information. Regards, Bill *# Whats next? *working on a new plugin for the 'Power' family, it is a JSON based tableless grid (which is much more than a grid) hope to release with examples, by the end of the week, preview - http://labs.blouweb.com/PowerGrid Need help, contribution, test.. []'s -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] --
Re: [web2py] Re: PowerFormWizard 0.1.4 - Bug Fixes and auto_validation (+ a new plugin for grids)
it is only on https://bitbucket.org/rochacbruno/powerformwizard/src but not updated yet.. on my todo-list to work on this. On Sat, Jan 19, 2013 at 10:43 PM, Bill Thayer bill.tha...@live.com wrote: Hi Bruno, Forgive me if I missed your updates. The link below does not work today. Where can I find the latest information. Regards, Bill *# Whats next? *working on a new plugin for the 'Power' family, it is a JSON based tableless grid (which is much more than a grid) hope to release with examples, by the end of the week, preview - http://labs.blouweb.com/**PowerGrid http://labs.blouweb.com/PowerGrid Need help, contribution, test.. []'s -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno** ] -- --
[web2py] Re: smartgrid - display linked_tables link as a dropdown button instead
Its high on our list as well. That plus a denser edit/create/view layout similar to Scubism's Solid Form. --
Re: [web2py] json validation
wow I'd never have thought of that - Thanks! Valid JSON On Saturday, January 19, 2013 6:37:08 PM UTC-6, Jonathan Lundell wrote: On 19 Jan 2013, at 4:21 PM, Bill Thayer bill@live.com javascript: wrote: My app stores EDA information (cad programs for designing microchips) so storing cell attributes in a json object and taking advantage of json rpc would be beneficial. I am trying out Alex's new 'json' data type and with the serializer and IS_JSON() validator. Using the controller function below I've manage to create a json object of cell parameters (aka, attributes). In the function's comments is the output from the function but this output fails validation in http://jsonlint.com/ saying that RESULTS: Parse error on line 1: myobj={L: [ ^ Expecting '{', '[' It looks like you're feeding jsonlint a string of the form myobj={some json object} instead of {some json object}. It's looking for a JSON object, which must begin with { or [, and it's finding 'm'. CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page after being inserted into my Oracle DB. def json_parameters(param_names): takes an array of parameter names which are attributes to a design cell then looks up the default value and unit in the attributes table and returns an array of json dictionary objects to be inserted in the cell's parameters field as a json object if param_names = [L, len, R, INST, model, REF] myobj={ L: [ 0.001, nH ], len: [ 1, ??m ], R: [ 0.5, Ohm ], INST: [ i, TEXT ], model: [ m, TEXT ], REF: [ r, TEXT ] } params={} for a in param_names: # dbg.set_trace() rows = db(db.attribute.name.lower()==a.lower()).select( db.attribute.name, db.attribute.default_value, db.attribute.unit) row = rows[0] param = ('{}'.format(row.default_value), '{}'.format(row.unit)) params.update({'{}'.format(row.name):param}) return json(params) Any idea which is correct or how to fix it? Thank you, Bill -- --