当前位置: 首页>>代码示例>>Python>>正文


Python User.fetch方法代码示例

本文整理汇总了Python中user.User.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python User.fetch方法的具体用法?Python User.fetch怎么用?Python User.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.User的用法示例。


在下文中一共展示了User.fetch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_password

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def add_password(username):
  password = str(request.form['password'])
  confirm_password = str(request.form['confirm_password'])
  existing_password = str(request.form['existing_password'])
  
  params = {
    'username': username,
    'password': password,
  }

  user = User.fetch(db, username)

  error = None

  if not user.getPassword(existing_password):
    error = "The existing password you entered was not found."

  if error is None and password != confirm_password:
    error = "The password you entered to confirm was not the same as entered originally."

  if error:
    return render_template('private/unknown.htm', error=error, **params)
    

  log_event('add-password', {
    'username': username,
    })

  user.addPasswordHash(createHash(password))

  params = {
      'username': username,
      'message': 'Your new password is now available.'
  }
  return render_template('private/index.htm', **params)
开发者ID:passwordly,项目名称:password.ly,代码行数:37,代码来源:private.py

示例2: get

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
    def get(self, uid):
        try:
            user = yield User.fetch(uid)
        except KeyError:
            self.clear_current_user()
            self.send_error(httplib.NOT_FOUND)
            return

        self.write(self.application.user_representation(user))
开发者ID:lchapple,项目名称:minterest,代码行数:11,代码来源:api.py

示例3: user_get_sites

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def user_get_sites(username):
  password = str(request.form['password'])

  user = User.fetch(db, username)

  sites = user and user.getSites(password)

  log_event('get-sites', {
    'username': username,
    'found': (sites is not None)
    })

  if sites is None:
    return '{"result": false, "sites": []}'
  else:
    return json.dumps({"result": True, "sites": sites})
开发者ID:passwordly,项目名称:password.ly,代码行数:18,代码来源:private.py

示例4: signup

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def signup():
  hash = str(request.form['hash'])
  site = str(request.form['site'])
  username = str(request.form['username'])
  
  error = None

  if User.fetch(db, username):
    error = "The username you selected is taken."
  elif not re.match(r'^[a-z]+$', username):
    error = 'Your username can only be made of lowercase letters'
  elif username in config.reserved:
    error = 'Sorry, the username you have selected is reserved'

  if error:
    params = {
      'hash': hash,
      'site': site,
      'new_username': username,
      'error': error
    }
    return render_template('public/password.htm', **params)
  else:
    db.hset('signups', username, json.dumps({
        'hash': hash,
        'site': site
      }))

    log_event('request-signup', {
      'username': username
      })

    return redirect((config.paypal_url + '?cmd=_xclick' + \
        '&item_name=Signup+for+password.ly:+{username}' + \
        '&item_number={username}&amount={price}&business={email}' + \
        '&custom={username}' + \
        '&currency_code=USD' + \
        '&notify_url={ipn}' + \
        '&cancel_return=http://password.ly/paypal/cancel' + \
        '&return=http://password.ly/{username}').format(
          username=username,
          email=config.paypal_email,
          price=config.price,
          ipn=config.ipn_url
        ))
开发者ID:passwordly,项目名称:password.ly,代码行数:47,代码来源:public.py

示例5: user_sync

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import fetch [as 别名]
def user_sync(username):
  password = str(request.form['password'])

  user = User.fetch(db, username)
  user_password = user.getPassword(password)

  if not user_password:
    log_event('sync-fail', {'username': username})

    return '{"result": false, "sites": {}}'

  # Sync theirs into ours (where we don't have anything)
  theirs = json.loads(request.form['sites'])
  ours = user_password.getAllComments()

  for site, comment in theirs.items():
    if not site in ours:
      user_password.setSite(site, comment)
      ours[site] = comment

  log_event('sync', {'username': username})
  return json.dumps({"result": True, "sites": ours})
开发者ID:passwordly,项目名称:password.ly,代码行数:24,代码来源:private.py


注:本文中的user.User.fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。