OK. Now I can see an error:
POST http://127.0.0.1:8000/myapplication/default/ajaxuserexist  500
INTERNAL SERVER ERROR

There is also information about issued ticet but I can't open it in
web browser, so I paste it below:


(dp1
S'output'
p2
S''
sS'layer'
p3
S'F:\\Programy\\web2py\\applications\\myapplication/controllers/
default.py'
p4
sS'code'
p5
S'# -*- coding: utf-8 -*-\n
\n#########################################################################
\n## This is a samples controller\n## - index is the default action of
any application\n## - user is required for authentication and
authorization\n## - download is for downloading files uploaded in the
db (does streaming)\n## - call exposes all registered services (none
by default)
\n#########################################################################
\n\ndef index():\n    """\n    example action using the
internationalization operator T and flash\n    rendered by views/
default/index.html or views/generic.html\n    """\n    response.flash
= T(\'Welcome to web2py\')\n    return dict(message=T(\'Hello World\'))
\n\n\ndef user():\n    """\n    exposes:\n    
http://..../[app]/default/user/login\n
http://..../[app]/default/user/logout\n    
http://..../[app]/default/user/register\n
http://..../[app]/default/user/profile\n    
http://..../[app]/default/user/retrieve_password\n
http://..../[app]/default/user/change_password\n    use
@auth.requires_login()\n        @auth.requires_membership(\'group name
\')\n        @auth.requires_permission(\'read\',\'table name
\',record_id)\n    to decorate functions that need access control\n
"""\n    return dict(form=auth())\n\n\ndef download():\n    """\n
allows downloading of uploaded files\n    
http://..../[app]/default/download/[filename]\n
"""\n    return response.download(request,db)\n\n\ndef call():\n
"""\n    exposes services. for example:\n    
http://..../[app]/default/call/jsonrpc\n
decorate with @services.jsonrpc the functions to expose\n    supports
xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv\n    """\n
session.forget()\n    return service()\n\n\n\ndef page2():\n    name =
request.vars.login\n    #db.auth_user.insert(name=name)\n    return
dict(name=name)\n\ndef ajaxuserexist():\n      username =
request.vars.values()[0]\n      return
db(db.auth_user.login==username).count() and \'yes\' or \'no\'\n\n
\nresponse._vars=response._caller(ajaxuserexist)\n'
p6
sS'traceback'
p7
S'Traceback (most recent call last):\n  File "gluon/restricted.py",
line 178, in restricted\n  File "F:\\Programy\\web2py\\applications\
\myapplication/controllers/default.py", line 67, in <module>\n  File
"gluon/globals.py", line 96, in <lambda>\n  File "F:\\Programy\\web2py\
\applications\\myapplication/controllers/default.py", line 64, in
ajaxuserexist\n  File "gluon/sql.py", line 1329, in __getattr__
\nKeyError: \'auth_user\'\n'
p8
s.


On 30 Cze, 22:59, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I'd like to know if the console reports any error when the ajax
> request is executed.
>
> On 30 Giu, 15:31, elfuego1 <elfue...@gmail.com> wrote:
>
> > I have firebug installed. What do you want me to look for?
> > You want to see some firebug output?
>
> > On 30 Cze, 22:25, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > I do not see anything wrong in this. Do you use firebug?
>
> > > On 30 Giu, 15:18, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > I hope I don't make your eyes bleed by puting all the code here but
> > > > there is no other way to show it to you.
> > > > I made change only in one place of the code to gather "login" value:
> > > > {login:value}
> > > > Oryginaly it was: {name:value}.
>
> > > >  $.post("{{=URL(r=request,c='default',f='ajaxuserexist')}}",
> > > > {login:value},function(result){
>
> > > > Below is the whole content of index.html
>
> > > > {{extend 'layout.html'}}
>
> > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> > > >     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> > > > <html>
> > > > <head>
> > > >     <meta http-equiv="Content-type" content="text/html;
> > > > charset=utf-8">
> > > >     <title>Ajax User Validation with web2py by Martin Sagastume</
> > > > title>
> > > >     <style type="text/css">
> > > >     <!--
> > > >     body { font-family:Arial,Verdana,Sans-serif; }
>
> > > >     input[type=text]{
> > > >         font-size:12px;
> > > >         color:#666666;
> > > >         background-color:#ffffff;
> > > >         padding-top:5px;
> > > >         width:200px;
> > > >         height:20px;
> > > >         border:1px solid #999999;
> > > >     }
>
> > > >     #resultbox { font-size:11px; }
> > > >     .msg { color:blue; }
> > > >     .success { color:green; }
> > > >     .error { color:red; }
> > > >     //-->
> > > >     </style>
> > > >     <script type="text/javascript"
> > > > src="{{=URL(r=request,c='static',f='jquery.js')}}"></script>
> > > >     <script type="text/javascript">
>
> > > >     var submit = false;
> > > >     $(document).ready(function(){
> > > >         $("form").submit(function() {
> > > >             return submit;
> > > >         });
> > > >     });
>
> > > >     function getData(value){
> > > >         if(value != ""){
> > > >             $
> > > > ("#resultbox").removeClass().addClass('msg').text('Validating...').fadeIn(10);
> > > >             $.post("{{=URL(r=request,c='default',f='ajaxuserexist')}}",
> > > > {login:value},function(result){
> > > >                 if(result=='yes'){
> > > >                     $
> > > > ("#resultbox").removeClass().addClass('error').text('Login already
> > > > taken').fadeTo(900,1);
> > > >                     submit = false;
> > > >                 }else{
> > > >                     $
> > > > ("#resultbox").removeClass().addClass('success').text('Login is
> > > > available for registration!').fadeTo(900,1);
> > > >                     submit = true;
> > > >                 }
> > > >             });
> > > >         }else{
> > > >             $("#resultbox").removeClass().addClass('msg').text('This
> > > > field is required');
> > > >         }
> > > >     }
>
> > > >     </script>
> > > > </head>
> > > > <body>
> > > >     <form id="form1" method="post" action="page2">
> > > >         <label for="country">Login:</label><br />
> > > >         <input type="text" id="login" name="login"
> > > > onblur="getData(this.value)" /><br />
> > > >         <div id="resultbox" class="msg"></div><br />
> > > >         <input type="submit" id="bsubmit" name="bsubmit"
> > > > value="Submit" />
> > > >     </form>
> > > > </body>
> > > > </html>
>
> > > > On 30 Cze, 22:12, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > This should give you an error because the print(username) is outside
> > > > > the funciton the function that defines username, after the function
> > > > > returns. How are you passing the username to the ajax call? Did you
> > > > > check with firebug that is calls the correct url?
>
> > > > > On 30 Giu, 15:01, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > There was NO error messages. The code just didn't work.
> > > > > > After inserting:
> > > > > > print repr(username) to default.py I got:
>
> > > > > > # -*- coding: utf-8 -*-
>
> > > > > > #########################################################################
> > > > > > ## This is a samples controller
> > > > > > ## - index is the default action of any application
> > > > > > ## - user is required for authentication and authorization
> > > > > > ## - download is for downloading files uploaded in the db (does
> > > > > > streaming)
> > > > > > ## - call exposes all registered services (none by default)
> > > > > > #########################################################################
>
> > > > > > def index():
> > > > > >     """
> > > > > >     example action using the internationalization operator T and 
> > > > > > flash
> > > > > >     rendered by views/default/index.html or views/generic.html
> > > > > >     """
> > > > > >     response.flash = T('Welcome to web2py')
> > > > > >     return dict(message=T('Hello World'))
>
> > > > > > def user():
> > > > > >     """
> > > > > >     exposes:
> > > > > >    http://..../[app]/default/user/login
> > > > > >    http://..../[app]/default/user/logout
> > > > > >    http://..../[app]/default/user/register
> > > > > >    http://..../[app]/default/user/profile
> > > > > >    http://..../[app]/default/user/retrieve_password
> > > > > >    http://..../[app]/default/user/change_password
> > > > > >     use @auth.requires_login()
> > > > > >         @auth.requires_membership('group name')
> > > > > >         @auth.requires_permission('read','table name',record_id)
> > > > > >     to decorate functions that need access control
> > > > > >     """
> > > > > >     return dict(form=auth())
>
> > > > > > def download():
> > > > > >     """
> > > > > >     allows downloading of uploaded files
> > > > > >    http://..../[app]/default/download/[filename]
> > > > > >     """
> > > > > >     return response.download(request,db)
>
> > > > > > def call():
> > > > > >     """
> > > > > >     exposes services. for example:
> > > > > >    http://..../[app]/default/call/jsonrpc
> > > > > >     decorate with @services.jsonrpc the functions to expose
> > > > > >     supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
> > > > > >     """
> > > > > >     session.forget()
> > > > > >     return service()
>
> > > > > > def page2():
> > > > > >     name = request.vars.login
> > > > > >     #db.auth_user.insert(name=name)
> > > > > >     return dict(name=name)
>
> > > > > > def ajaxuserexist():
> > > > > >       username = request.vars.values()[0]
> > > > > >       return  db(db.auth_user.login==username).count() and 'yes' or
> > > > > > 'no'
>
> > > > > > print repr(username)
> > > > > > response._vars=response._caller(index)
>
> > > > > > On 30 Cze, 21:51, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > You can simplify it a bit
>
> > > > > > > def ajaxuserexist():
> > > > > > >       username = request.vars.values()[0]
> > > > > > >       return  db(db.auth_user.login==username).count() and 'yes' 
> > > > > > > or
> > > > > > > 'no'
>
> > > > > > > although it will not solve your problem.
> > > > > > > There is nothing special in table auth_user so the problem is
> > > > > > > somewhere else.
>
> > > > > > > I suggest you insert a print repr(username).
> > > > > > > Do you get any thicket? What does it say?
>
> > > > > > > massimo
>
> > > > > > > On 30 Giu, 14:29, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > > > During registration I want to check on the fly, if login chosen 
> > > > > > > > by the
> > > > > > > > user is already in use or is it not in db and available to be 
> > > > > > > > used.
>
> > > > > > > > def ajaxuserexist():
> > > > > > > >     username = request.vars.values()[0]
> > > > > > > >     query = (db.auth_user.login==username)
> > > > > > > >     numres = db(query).count()
> > > > > > > >     if numres > 0 :
> > > > > > > >        return 'yes'
> > > > > > > >     else:
> > > > > > > >         return 'no'
>
> > > > > > > > When I test it on any other table that doesn't have prefix 
> > > > > > > > auth_ then
> > > > > > > > the above code works, but unfortunatelly I need to test 
> > > > > > > > auth_user
> > > > > > > > table :-(
>
> > > > > > > > On 30 Cze, 21:19, Chris S <sanders.ch...@gmail.com> wrote:
>
> > > > > > > > > Probably a dumb question, but what are you checking the user 
> > > > > > > > > against?
>
> > > > > > > > > Both my and your example above are checking for username and 
> > > > > > > > > you
> > > > > > > > > didn't define a username in your auth_user.
>
> > > > > > > > > Your query then is not working as:
>
> > > > > > > > > def userexist(emailcheck):
> > > > > > > > >     if db(db.auth_user.email==emailcheck).count() > 0:
> > > > > > > > >         return 'yes'
> > > > > > > > >     else:
> > > > > > > > >         return 'no'
>
> > > > > > > > > I know I've returned searches on auth_user it's no different 
> > > > > > > > > than
> > > > > > > > > other tables.  Just gotta find whey your getting no results.  
> > > > > > > > > Might
> > > > > > > > > help if you post the exact search code that goes with the 
> > > > > > > > > above
> > > > > > > > > auth_user and the error message that's generated.
>
> > > > > > > > > On Jun 30, 2:12 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > > > > > Since I had added some fields (and intend to customize it 
> > > > > > > > > > further) to
> > > > > > > > > > my auth_user table the code for auth_user in db.py looks 
> > > > > > > > > > like that:
>
> > > > > > > > > > from gluon.tools import *
> > > > > > > > > > auth=Auth(globals(),db)
>
> > > > > > > > > > db.define_table('auth_user',
> > > > > > > > > >     SQLField('login', 'string', length=50, default=''),
> > > > > > > > > >     SQLField('password', 'password', length=512, 
> > > > > > > > > > readable=False,
> > > > > > > > > > label='Password'),
> > > > > > > > > >    
>
> ...
>
> więcej »

Reply via email to