示例#1
0
def add():
    name = request.GET.get('name')
    password = request.GET.get('password')
    lng = request.GET.get('lng')
    lat = request.GET.get('lat')
    user = User(name=name, password=password)
    result = session.add(user)
    return "result is %s" % result
    dbsession.commit()
    return 'user %s added!' % (name)
示例#2
0
def add():
    name = request.GET.get('name')
    password = request.GET.get('password')
    lng = request.GET.get('lng')
    lat = request.GET.get('lat')
    user = User(name=name, password=password)
    result = session.add(user)
    return "result is %s" %result
    dbsession.commit()
    return 'user %s added!' % (name)
示例#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 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}
示例#5
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}
示例#6
0
def add_item():
    title = request.GET.get('title')
    price = request.GET.get('price')
    desc = request.GET.get('description')
    latlng = request.GET.get('latlng')
    [lat, lng] = latlng.split(',')
    username = request.GET.get('username')

    user = dbsession.query(User).filter_by(name=username).first()
    if not user:
        #return HTTPError(404, 'User not found.')
        return {'status' : 'error'}
    
    item = Item(title=title, price=price, desc=desc, location='POINT(%s %s)' %(lat, lng))
    user.itemlist.append(item)
    dbsession.commit()
    #return "item %s added!" % title
    return {'status' : 'ok'}
示例#7
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()
示例#8
0
def add_item():
    title = request.GET.get('title')
    price = request.GET.get('price')
    desc = request.GET.get('description')
    latlng = request.GET.get('latlng')
    [lat, lng] = latlng.split(',')
    username = request.GET.get('username')

    user = dbsession.query(User).filter_by(name=username).first()
    if not user:
        #return HTTPError(404, 'User not found.')
        return {'status': 'error'}

    item = Item(title=title,
                price=price,
                desc=desc,
                location='POINT(%s %s)' % (lat, lng))
    user.itemlist.append(item)
    dbsession.commit()
    #return "item %s added!" % title
    return {'status': 'ok'}
示例#9
0
 def on_button_clicked(self, widget):
     dbsession.commit()