Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 819815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:22:20+00:00 2026-05-15T02:22:20+00:00

(1) is this way : http://code.google.com/intl/en/appengine/articles/djangoforms.html (2) is write by self : #/usr/bin/env python2.5

  • 0

(1) is this way : http://code.google.com/intl/en/appengine/articles/djangoforms.html

(2) is write by self :

#/usr/bin/env python2.5
#----------------------------
# Datastore models for user & signup
#----------------------------

from base64 import b64encode as b64
from hashlib import md5, sha256
from random import randint
from time import time

from google.appengine.ext import db


N_SALT = 8             # length of the password salt


def salt_n_hash(password, salt=None):
    """
    Generate a salt and return in base64 encoding the hash of the
    password with the salt and the character '$' prepended to it.
    """
    salt = salt or b64( ''.join(chr(randint(0, 0xff)) for _ in range(N_SALT)) )
    return salt + '$' + b64( sha256(salt+password.encode("ascii")).digest() )


class User(db.Model):
    nickname = db.StringProperty(required=True)
    email = db.EmailProperty(required=True)
    pwd = db.StringProperty(required=True)
    suspended = db.BooleanProperty(default=True)

    @classmethod
    def authenticate(klass, nickname, password):
        """Return an User() entity instance if password is correct"""
        user = klass.get_by_key_name(nickname)
        if user:
            n_salt = user.pwd.index('$')
            if user.pwd == salt_n_hash(password, salt=user.pwd[:n_salt]):
                return user

    def __eq__(self, other):
        return self.nickname == other.nickname


def signup_id(nickname):
    return md5( nickname + repr(time()) ).hexdigest()


class UserSignup(db.Model):
    user = db.ReferenceProperty(User, required=True)
    date = db.DateProperty(auto_now_add=True)

which way is better ,

or did you have better way to do this , ex: a simply form Validation framework,

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:22:21+00:00Added an answer on May 15, 2026 at 2:22 am

    If you’re using Django, djangoforms is definitely the way to go. If tipfy or other light-weight frameworks, try wtforms (it’s also in the tipfy source tree).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 458k
  • Answers 458k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are close, just remove the 'pk' from the json… May 15, 2026 at 11:09 pm
  • Editorial Team
    Editorial Team added an answer One of the bigger differences is that the armv6 architecture… May 15, 2026 at 11:09 pm
  • Editorial Team
    Editorial Team added an answer Given their placement (right where two triangles butt up against… May 15, 2026 at 11:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.