[web2py] Re: Use reserved Keyword 'response'
El jueves, 11 de mayo de 2017, 19:53:29 (UTC+2), Anthony escribió: > > Please show your code. > Hi Anthony, Thanks for your answer. My code is: - @request.restful() def getOrder(): response.view = 'generic.json' def GET(*args,**vars): patterns = [ "/p/:idOrder" ] # . res = {} res.update({'response': {'success': True, 'Key': Key, 'data': dataOrder, 'Code': .}}) return dict(res) return dict(GET=GET) - This way I can't return 'response' expression. Thank you for your support. Regards, Francisco > > On Thursday, May 11, 2017 at 12:28:37 PM UTC-4, Francisco García wrote: >> >> Hello all, >> >> In a service Restful I need to return a dict in the form: >> >> {'response' : {'data' : .}} >> >> The problem is that I can't use 'response' Keyword this way. >> I get the error: >> keyword can't be an expression >> I would like to know if there is a way to do that. >> Thank you in advance. >> >> Regards, >> Francisco >> >> -- 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 reserved Keyword 'response'
I solved the problem: from gluon.globals import json @request.restful() def getOrder(): response.view = 'generic.json' def GET(*args,**vars): patterns = [ "/p/:idOrder" ] # . res = {} res.update({'response': {'success': True, 'Key': Key, 'data': dataOrder, 'Code': .}}) return (json(res)) return dict(GET=GET) Thanks. Regards Francisco. El viernes, 12 de mayo de 2017, 9:25:44 (UTC+2), Francisco García escribió: > > El jueves, 11 de mayo de 2017, 19:53:29 (UTC+2), Anthony escribió: >> >> Please show your code. >> > > Hi Anthony, > Thanks for your answer. > > My code is: > > - > @request.restful() > def getOrder(): > response.view = 'generic.json' > > def GET(*args,**vars): > patterns = [ > "/p/:idOrder" > ] > > # . > res = {} > res.update({'response': {'success': True, 'Key': Key, 'data': > dataOrder, 'Code': .}}) > return dict(res) > > return dict(GET=GET) > - > > This way I can't return 'response' expression. > > Thank you for your support. > Regards, > Francisco > > > >> >> On Thursday, May 11, 2017 at 12:28:37 PM UTC-4, Francisco García wrote: >>> >>> Hello all, >>> >>> In a service Restful I need to return a dict in the form: >>> >>> {'response' : {'data' : .}} >>> >>> The problem is that I can't use 'response' Keyword this way. >>> I get the error: >>> keyword can't be an expression >>> I would like to know if there is a way to do that. >>> Thank you in advance. >>> >>> Regards, >>> Francisco >>> >>> -- 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: Extracting values out of a python list as individual entities
This is what i need Tony, I want to be able to count elements from the database and use what i get from the database in my array without having to explicitly hard code the number. If i have 5 elements i want to be able show those 5 elements and if they are 8 i want to be able to use the 8 element, whatever number of elements is found in the table should be able to automatically be accommodated in the JavaScript array for the slide show. What i got from Stack Overflow works, I am able to extract elements individually as requested but the problem comes when i have to use them in my JavaScript array. I have to be specific and individually display them in the array. Cant i just put a reference like this which holds any number of elements and have those elements offloaded into the array as below: *FUNCTION:* *def form1Details():form=db.compForm(request.args(0)) forms=db(db.compFormPages.formName==form.id).select(db.compFormPages.ALL) return dict(forms=forms)* *VIEW:* *{{for pic in forms:}}{{pass}}images = ["{{=URL('download', args=pic.formImage)}}"]; descriptions=['{{=pic1.formTitle}}'];* and have this code show all the pics and their descriptions and not do like below where i have to be specific with the number of elements i want in an array!! *images = ["{{=URL('download', args=pic1.formImage)}}", "{{=URL('download', args=pic2.formImage)}}", "{{=URL('download', args=pic3.formImage)}}"];descriptions=['{{=pic1.formTitle}}', '{{=pic2.formTitle}}', '{{=pic3.formTitle}}'];*I do not not know if i give sense but i hope i do. On Thursday, May 11, 2017 at 8:20:23 PM UTC+2, Anthony wrote: > > Are you still looking for help on this? If so, please explain what more > you need beyond the answer you accepted on Stack Overflow: > http://stackoverflow.com/a/43682846/440323. > > Anthony > > On Thursday, May 11, 2017 at 6:51:34 AM UTC-4, mostwanted wrote: >> >> Please someone out there coz I'm pulling out my hairs at this point: >> >> I want to extract pictures from within a list of elements extracted from >> the database and store them inside a JavaScript array for a slide show. >> >> >> *CONTRLOLLER* >> >> def form1Details(): >> form=db.compForm(request.args(0)) >> forms=db(db.compFormPages.formName==form.id).\ >> select(db.compFormPages.ALL) >> return locals() >> >> the images are in variable forms so i wanna display them in my view such >> that each picture is stored individually inside a JavaScript array for a >> slide show like below >> >> >> *VIEW*{{for pic in forms:}} >>