Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
unable to get values from a login page in web.py python
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
shiva krishna  
View profile  
 More options Oct 9 2012, 10:31 am
From: shiva krishna <shivakrsh...@gmail.com>
Date: Tue, 9 Oct 2012 07:31:20 -0700 (PDT)
Local: Tues, Oct 9 2012 10:31 am
Subject: unable to get values from a login page in web.py python

I am using python web.py framework to create a small web application which
has just

1. Login screen (Authentication)

2. Screen with list of records(After succesfull login)

Presently i am trying to create a login screen authentication

I have created an `index.py` file with code as below

**index.py**

    import os
    import sys
    import web
    from web import form
    from web.contrib.auth import DBAuth

    render = web.template.render('templates/')

    urls = (
      '/',   'Login',
    )

    app = web.application(urls, globals())
    db = web.database(dbn='mysql', db='Python_Web', user='root',
pw='redhat')

    class Login:

        login_form = form.Form(
            form.Textbox('username', form.notnull),
            form.Password('password', form.notnull),
            form.Button('Login'),
            )

        def GET(self):
            form = self.login_form()
            return render.login(form)

        def POST(self):
    #        if not self.login_form.validates():
    #            return render.login(self.login_form)
            post = self.login_form()
            username = post['username'].value
            print username,">>>>>>>>>>>>>>>>>>>>>>username"
            password = post['password'].value
            ident = db.select('user', where='user_login=$username',
vars=locals())

    if __name__ == "__main__":
        web.internalerror = web.debugerror
        app.run()    

My **login.html** code

    $def with (form)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Log in</title>
    </head>
    <body>
    <div id="container">
      <h1>Log in Details</h1>
      <form action="" method="post" accept-charset="utf-8">
        <p><label for="username">Username:
        <input type="text" name="username" id="username" maxlength="254"
tabindex="1" />
        </label></p>
        <p><label for="password">Password:
        <input type="password" name="password" id="password"
maxlength="254" tabindex="2" />
        </label></p>
        <p><label for="Login"></label><button id="Login"
name="Login">Login</button></p>  
      </form>

    </div>
    </body>

When i run the above file with url `www.localhost:9080` in browser i can
see the screen with fields `username, password and login` button , but when
i enter username and password and  clicked `login` button and tried to
print the username i cannot fetch any data from the browser and the result
showing is as below

    None >>>>>>>>>>>>>>>>>>>>>>username
    0.0 (1): SELECT * FROM user WHERE user_login=NULL

Can anyone let me why i am unable fetch the details entered through browser
?, am i missing anything in the above code and finally all my intention is  

to create a `login` page and `validate` the user details by checking in the
database

and `redirect` to the next page if user exits

I request to please help me out in writing the code for fetching the
details from the browser and checking in the database and redirecting to
another html page if user exists. I am really stuck and breaking my heads
to complete this process


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anand Chitipothu  
View profile  
 More options Oct 9 2012, 11:15 am
From: Anand Chitipothu <anandol...@gmail.com>
Date: Tue, 9 Oct 2012 20:45:06 +0530
Local: Tues, Oct 9 2012 11:15 am
Subject: Re: [webpy] unable to get values from a login page in web.py python

You need to call form.validates() or form.fill() to fill the form with
values from input data.

Typical use is:

    form = self.login_form()
    # render the form again if there are errors
    if not form.validates():
        return form.render()
    # do something with the form here

Anand


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »