예제 #1
0
def signin():
    username = request.POST.get('username')
    password = request.POST.get('password')
    email = request.POST.get('email')
    if not username or not password or not email:
        return HTTPError(404, 'no data.')

    password_encrypt = encrypt(username + password)
    user = User(name=username, password=password_encrypt, email=email)
    dbsession.add(user)
    dbsession.commit()
    session = request.environ['beaker.session']
    session['username'] = username
    session.save()
    return {'username': username}
예제 #2
0
def signin():
  username = request.POST.get('username')
  password = request.POST.get('password')
  email = request.POST.get('email')
  if not username or not password or not email : 
    return HTTPError(404, 'no data.')

  password_encrypt = encrypt( username + password )
  user = User(name=username, password=password_encrypt, email=email)
  dbsession.add(user)
  dbsession.commit()
  session = request.environ['beaker.session']
  session['username'] = username
  session.save()
  return {'username' : username}
예제 #3
0
def populate_db():
    users = dbsession.query(User).all()
    if not users:
        jimmy = User(name='jimmy', password='******')
        jimmy.itemlist.append(
            Item(title='iphone1',
                 price='1000',
                 desc='sixty percent new',
                 location='POINT(%s %s)' % ('31.199', '121.587')))
        jimmy.itemlist.append(
            Item(title='iphone2',
                 price='1500',
                 desc='sixty-five percent new',
                 location='POINT(%s %s)' % ('31.299', '121.587')))
        jimmy.itemlist.append(
            Item(title='iphone3',
                 price='2000',
                 desc='seventy percent new',
                 location='POINT(%s %s)' % ('31.099', '121.587')))
        jimmy.itemlist.append(
            Item(title='iphone4',
                 price='3000',
                 desc='eighty percent new',
                 location='POINT(%s %s)' % ('31.199', '121.487')))
        jimmy.itemlist.append(
            Item(title='iphone4s',
                 price='4000',
                 desc='ninty percent new',
                 location='POINT(%s %s)' % ('31.099', '121.787')))
        jimmy.itemlist.append(
            Item(title='iphone5',
                 price='9999',
                 desc='comming soon...',
                 location='POINT(%s %s)' % ('31.199', '121.587')))
        dbsession.add(jimmy)

        lisa = User(name='lisa', password='******')
        lisa.itemlist.append(
            Item(title='iphone6',
                 price='99999',
                 desc='future...',
                 location='POINT(%s %s)' % ('31.299', '121.387')))
        lisa.itemlist.append(
            Item(title='iphone7',
                 price='999999',
                 desc='future...',
                 location='POINT(%s %s)' % ('31.199', '121.387')))
        dbsession.add(lisa)

        dbsession.add(User(name='bob', password='******'))
        dbsession.add(User(name='john', password='******'))
        dbsession.commit()
예제 #4
0
def populate_db():
    users = dbsession.query(User).all()
    if not users:
        jimmy = User(name='jimmy', password='******')
        jimmy.itemlist.append(Item(title='iphone1', price='1000', desc='sixty percent new', location='POINT(%s %s)' %('31.199', '121.587')))
        jimmy.itemlist.append(Item(title='iphone2', price='1500', desc='sixty-five percent new', location='POINT(%s %s)' %('31.299', '121.587')))
        jimmy.itemlist.append(Item(title='iphone3', price='2000', desc='seventy percent new', location='POINT(%s %s)' %('31.099', '121.587')))
        jimmy.itemlist.append(Item(title='iphone4', price='3000', desc='eighty percent new', location='POINT(%s %s)' %('31.199', '121.487')))
        jimmy.itemlist.append(Item(title='iphone4s', price='4000', desc='ninty percent new', location='POINT(%s %s)' %('31.099', '121.787')))
        jimmy.itemlist.append(Item(title='iphone5', price='9999', desc='comming soon...', location='POINT(%s %s)' %('31.199', '121.587')))
        dbsession.add(jimmy)
        
        lisa = User(name='lisa',  password='******')
        lisa.itemlist.append(Item(title='iphone6', price='99999', desc='future...', location='POINT(%s %s)' %('31.299', '121.387')))
        lisa.itemlist.append(Item(title='iphone7', price='999999', desc='future...', location='POINT(%s %s)' %('31.199', '121.387')))
        dbsession.add(lisa)
        
        dbsession.add(User(name='bob',   password='******'))
        dbsession.add(User(name='john',  password='******'))
        dbsession.commit()