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


Python User.get方法代码示例

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


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

示例1: do_register

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def do_register():
    messages = {}
    user_data = {
        'display'  : request.form.get('display'),
        'username' : request.form.get('username'),
        'password' : request.form.get('password'),
        'confirm'  : request.form.get('confirm'),
        'email'    : request.form.get('email')
    }

    user = User.get(user_data['username'])

    if user_data['password'] != user_data['confirm']:
        messages['error'] = errors.get("pass_match")
    elif display_taken(user_data['display']):
        messages['error'] = errors.get("display_in_use")
    elif user and user.check_password(user_data['password']):
        login_user(user, force=True)
    elif user:
        messages['error'] = errors.get("user_in_use")
    else:
        add_user_to_db(user_data)

        user = User.get(user_data['username'])
        login_user(user, force=True)

        user.send_activation_email()
    return messages
开发者ID:gorel,项目名称:poker-server,代码行数:30,代码来源:utils.py

示例2: user_start_page

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def user_start_page(udid):
    user = User.get(udid)
    if not user:
        User.new(udid)
        user = User.get(udid)

    ret = {}
    ret['action'] = 'get_start_page'
    ret['page'] = user.page
    return jsonify(ret)
开发者ID:senryxie,项目名称:GN-Drive,代码行数:12,代码来源:application.py

示例3: DoRemoveStar

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
 def DoRemoveStar():
   fav = Favorite.get_by_key_name(map_key.name(), parent=user_key)
   if fav:
     user = User.get(user_key)
     user.favourite_count -= 1
     user.put()
     fav.delete()
开发者ID:n-community,项目名称:numa,代码行数:9,代码来源:map.py

示例4: post_feedback

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def post_feedback(udid):
    user = User.get(udid)
    if not user:
        User.new(udid)
        user = User.get(udid)

    feedback = request.args.get('feedback', '')
    ret = {}
    ret['udid'] = user.udid
    ret['feedback'] = feedback or '未反馈'
    ret['action'] = 'feedback'

    ret['r'] = 1
    if feedback:
        ret['r'] = 0
    return jsonify(ret)
开发者ID:senryxie,项目名称:GN-Drive,代码行数:18,代码来源:application.py

示例5: login_post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def login_post():
    user = User.get(request.form["text-username"])
    if user and user.password == request.form["text-password"]:
        login_user(user)
        return redirect(url_for("home"))
    else:
        return login(message="Wrong username or password!")
开发者ID:jsjolund,项目名称:little-webshop,代码行数:9,代码来源:login.py

示例6: assign

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def assign():
    if not current_user.is_admin():
        return 'Not Authorized', 500
    dataset = request.args.get('dataset')
    batch = int(request.args.get('batch'))
    user = User.get(request.args.get('user'))
    with codecs.open(os.path.join(DATA_DIR, dataset+'.json'), 'r', 'utf-8') as f:
        lines = f.readlines()
    dic = json.loads(lines[batch])
    dic['assignedTo'].append(user.get_id())
    userDict = user.load()
    if dataset not in userDict:
        userDict[dataset] = {}
    assert str(batch-1) not in userDict[dataset] and str(batch+1) not in userDict[dataset]		
    userDict[dataset][str(batch)] = dic
    user.save(userDict)
    lines[batch] = json.dumps(dic) + '\n'
    with codecs.open(os.path.join(DATA_DIR, dataset+'.json'), 'w', 'utf-8') as f:
        for line in lines:
            f.write(line)
    with codecs.open(os.path.join(DIRECTORY, 'metaData.json'), 'r', 'utf-8') as f:
        meta = json.loads(f.read())
    meta['assignments'][dataset][str(batch)] = username
    with codecs.open(os.path.join(DIRECTORY, 'metaData.json'), 'w', 'utf-8') as f:
        f.write(json.dumps(meta))
    return 'OK',200
开发者ID:Mordeaux,项目名称:gfl_web,代码行数:28,代码来源:__init__.py

示例7: get_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def get_user(user_id):
    if CACHE.get(user_id):
        user = CACHE.get(user_id)
    else:
        user = User.get(user_id)
        CACHE[user_id] = user
    return user
开发者ID:yupbank,项目名称:social_analytic_tool,代码行数:9,代码来源:report.py

示例8: load_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def load_user(userid):
    if userid not in mc_challenge_mgr.users:
        print ">>>>> load_user(%s) -> users = %r... reloading users" % (userid, mc_challenge_mgr.users)
        load_users(mc_challenge_mgr)
    u = User.get(mc_challenge_mgr.users, userid)
    if u is None:
        logout_impl()
开发者ID:simu,项目名称:skyblock-challenge-mgr,代码行数:9,代码来源:mc_challenge_mgr.py

示例9: DoAddStar

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
 def DoAddStar():
   fav = Favorite.get_by_key_name(map_key.name(), parent=user_key)
   if not fav:
     user = User.get(user_key)
     user.favourite_count += 1
     fav = Favorite(key_name=map_key.name(), parent=user, map_id=self.map_id)
     db.put(user)
     db.put(fav)
开发者ID:n-community,项目名称:numa,代码行数:10,代码来源:map.py

示例10: DoUpdateUser

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
 def DoUpdateUser(old_bar, new_bar, change_rated_count):
   user = User.get(self.user.key())
   if old_bar: user.rating_histogram[old_bar] -= abs(delta)/delta
   if new_bar: user.rating_histogram[new_bar] += abs(delta)/delta
   user.ratings += delta
   if change_rated_count:
     user.rated_map_count += delta
   user.put()
开发者ID:n-community,项目名称:numa,代码行数:10,代码来源:map.py

示例11: find_in_area

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
 def find_in_area(cls, area, limit=20, user_id=None):
   query = Location.all().order("-created")
   if user_id != None:
     user = User.get(long(user_id)) 
     query.filter("user_id =", user_id)
   return Location.bounding_box_fetch(query,
                                     geotypes.Box(area[0], area[1], area[2], area[3]),
                                     max_results=limit)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:10,代码来源:location.py

示例12: to_dict

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
 def to_dict(self):
     ''' Returns a hash of a booking in the database '''
     data = {}
     place = Place.get(Place.id == self.place)
     user = User.get(User.id == self.user)
     data['place_id'] = place.id
     data['user_id'] = user.id
     data['is_validated'] = self.is_validated
     data['date_start'] = self.date_start.strftime("%Y/%m/%d %H:%M:%S")
     data['number_nights'] = self.number_nights
     return super(PlaceBook, self).to_dict(self, data)
开发者ID:rickharris-dev,项目名称:airbnb_clone,代码行数:13,代码来源:place_book.py

示例13: do_activate

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def do_activate(payload):
    s = URLSafeSerializer(app.config['SECRET_KEY'])
    try:
        username = s.loads(payload)
    except BadSignature:
        abort(404)

    user = User.get(username)
    if not user or user.is_active():
        abort(404)
    user.set_active()
    flash('Account activated')
开发者ID:gorel,项目名称:poker-server,代码行数:14,代码来源:utils.py

示例14: delete_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
 def delete_user():
     item = self.ui.table_user.currentItem()
     if item is None:
         return
     idx = self.ui.table_user.currentIndex()
     name = item.text(0)
     user = User.get(name)
     if isinstance(user, PersonUser):
         print('Cannot delete Person User:', name)
         return
     user.stop = True
     User.users.pop(name)  # Let gc do its job...
     self.ui.table_user.takeTopLevelItem(idx.row())
开发者ID:jbvsmo,项目名称:privateTPPsystem,代码行数:15,代码来源:main.py

示例15: login

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get [as 别名]
def login():
	if request.method == 'GET':
		return render_template('_login.html')
	
	r = request.json
	if r is not None:
		user = User.get(r.get('username'))
		print 'login -> <%s>' % user
		if user is not None and user.authenticate(r.get('password')):
			login_user(user)
			return json.dumps({})

	abort(500)
开发者ID:virtualdreams,项目名称:postit,代码行数:15,代码来源:app.py


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