update via ajax getting error.

33 views
Skip to first unread message

Avi A

unread,
Jan 29, 2014, 5:09:40 PM1/29/14
to web...@googlegroups.com
Hi,
I am trying something like that: (render current api key and update it if clicking)

on the view:

<button  type="button" id="change_api_key">Get new api key</button>
<div id= "target">{{=LOAD('default','api_key.load',ajax=True)}}</div>

        <script type="text/javascript">
$(document).ready(function(){
  $("#change_api_key").click(function(){
    url = 'api_key.load/1' ;
    ajax(default/url, '', 'target')
      });
  });

</script>


and the controller:

import uuid
def api_key():
    if request.args(0):
        db(db.auth_user.id == auth.user.id).update(db.auth_user.api_key == uuid.uuid4())  #error line

    my_api_key = db(db.auth_user.id == auth.user.id).select(db.auth_user.api_key)
    return locals()

the error i am getting:
TypeError: update() takes exactly 1 argument (2 given)
Thanks.




Niphlod

unread,
Jan 29, 2014, 5:18:35 PM1/29/14
to web...@googlegroups.com
the syntax is wrong....
it's

db(condition).update(column_name=value)

not

db(condition).update(db.table.column_name=value)

Avi A

unread,
Jan 29, 2014, 5:30:04 PM1/29/14
to web...@googlegroups.com
Thanks,
I'm still getting the same error.

Avi A

unread,
Jan 29, 2014, 5:42:03 PM1/29/14
to web...@googlegroups.com
   db(db.auth_user.id == auth.user.id).update(api_key == uuid.uuid4())
TypeError: update() takes exactly 1 argument (2 given)

Avi A

unread,
Jan 29, 2014, 5:54:18 PM1/29/14
to web...@googlegroups.com
I also get on the error log on the Variables :
).update  undefined

Anthony

unread,
Jan 29, 2014, 6:03:53 PM1/29/14
to web...@googlegroups.com
Should be .update(api_key=uuid.uuid4()).

Anthony

אבי אברמוביץ

unread,
Jan 29, 2014, 6:08:13 PM1/29/14
to web...@googlegroups.com

Ooops. Great 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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Rkdwg23tWRM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages