Query failing in Taskqueue

30 views
Skip to first unread message

test.w...@gmail.com

unread,
Jun 29, 2015, 3:20:33 AM6/29/15
to google-a...@googlegroups.com, meenaks...@accenture.com, pines...@accenture.com

 

We have a Web2py application hosted on Google app engine.

We are trying to implement Taskqueue for fetching record from tables, we are passing the filter field (date type) and number of years as parameters. These parameters will be then passed to a Query to fetch the data from the Database.

Please find the code snippet as given below:

Task_handler() function accepts the 2 input parameters and calls the taskqueue which is defined in the task_process() function. In task_process() function we are calculating the date based on the number of years parameters and using it in the query to fetch the records older than the calculated date.

def task_handler():

      if len(request.args):

                field= request.args[0]

filter=int(request.args[1])

       return taskqueue.add(url=URL('task_process'),params={’field’:field,'diff': filter,},method="POST")

      

def task_process():

                field= request.form.get(‘field’)

diff = request.form.get('diff')

    filter_date = datetime.date.today() + datetime.timedelta(-(365*(diff)))

    result = []

    result = db(field < filter_date).select()

 

Note :
field in this case is db.<tablename>.<columnname>

 

If we directly use the input parameter in query, it fails due to datatype mismatch.

So we tried by hardcoding the table field name in the query but got Attribute Error for that.

 

Kindly provide your inputs on what are we missing here or doing wrong.

 

Thanks.

Nick (Cloud Platform Support)

unread,
Jun 29, 2015, 3:43:40 PM6/29/15
to google-a...@googlegroups.com, test.w...@gmail.com, pines...@accenture.com, meenaks...@accenture.com
Hi,

Unfortunately, this forum isn't the right place to look for technical support on specific issues, or 1-on-1 support.

For that, you should either purchase a support package or post to StackOverflow.

If you believe you've noticed an actual issue on the platform, feel free to open an issue in the public issue tracker for App Engine.

Whether you post to StackOverflow or the public issue tracker, you should include enough details to explain what you're doing, what you expect to see, and if possible, enough code to allow someone to reproduce the issue. 

As to your specific issue here, it seems odd that you are attempting to use url=URL('task_process'), when task_process is a function. Perhaps there is some framework you're using that converts this to a proper URL on your app which routes to that function, but this is left out of your post, and I can only guess. In addition, it seems odd that you can reference the variable "request", even though it isn't part of the function arguments or declared within the functions.

At any rate, I hope the above advice is helpful to you and that you can move on to post this issue to the correct forum, and/or get a support package for 1-on-1 support.

Have a nice day!

-- Nick

Nick (Cloud Platform Support)

unread,
Jun 29, 2015, 3:45:16 PM6/29/15
to google-a...@googlegroups.com, pay...@google.com, meenaks...@accenture.com, test.w...@gmail.com, pines...@accenture.com
Ah, at any rate, I can see that you're using web2py. In addition to my advice from my first post, you should look into whether this framework might be impacting what you see, and also, when you create your StackOverflow thread / public issue tracker issue, you should specify which database you're using, as the syntax you show is unfamiliar to me, and possibly to others.

Best wishes,

-- Nick
Reply all
Reply to author
Forward
0 new messages