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


Python User.get方法代码示例

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


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

示例1: adminActionRoute

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def adminActionRoute(action=None, id=None):
    if not loggedIn():
        return flashy('/', 'You must be logged in to do that!', 'error')
    if not action:
        return flashy('/', 'There was an error processing your request!', 'error')
    if not request.form.get('isact') and not id or id and not id.isdigit(): #Best ifstatement EVAR
        return flashy('/', 'Invalid or maliformed request!', 'error')
    if action == 'delete_proj':
        q = [i for i in Project.select().where(Project.id == int(id))]
        if not len(q):
            return flashy('/', 'Invalid Project ID (%s)' % id, 'error')
        q[0].delete_instance()
        return flashy('/', 'Deleted Project #%s!' % id, 'success')
    elif action == 'add_proj':
        q = [i for i in Project.select().where(Project.name == request.form.get('pname'))]
        if len(q): return flashy('/admin', 'There is already a project with the name "%s"' % request.form.get('pname'), 'error')
        p = Project(
            name=request.form.get('pname'),
            author=User.get(User.id==session.get('uid')),
            desc=request.form.get('pdesc'),
            url=request.form.get('purl'),
            repo_type=request.form.get('repotype'),
            repo_name=request.form.get('pgitname').lower(),
            repo_url=request.form.get('giturl'))
        p.save()
        return flashy('/admin', 'Added project "%s" (ID #%s)' % (p.name, p.id), 'success')
开发者ID:b1naryth1ef,项目名称:buildy,代码行数:28,代码来源:main.py

示例2: get_user_exercises

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def get_user_exercises(user_id, ex_id):
	if Token.invalid(user_id, request.path, request.json):
		abort(403)
	user = User.get(user_id)
	if user == None:
		abort(404)
	exercise = user.getExercise(ex_id)
	if exercise == None:
		abort(404)
	return jsonify(exercise)
开发者ID:Ododo,项目名称:flask-api,代码行数:12,代码来源:main.py

示例3: get_token_by_id

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def get_token_by_id(user_id):
	try :
		password = request.json['password']
	except Exception:
		abort(400)
	user = User.get(user_id)
	if user == None:
		abort(404)
	if user.checkPassword(password):
		token = Token.add(user.id)
		return jsonify({'user': user.id, 'token': token.token}), 201
	else:
		abort(403)
开发者ID:Ododo,项目名称:flask-api,代码行数:15,代码来源:main.py

示例4: star_post

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def star_post(id):
  if not g.db.doc_exist(id):
    abort(404)
  post = Post.get(id)
  uid = session.get('uid')
  user = User.get(uid)
  if uid not in post.stars:
    post.stars.add(uid)
    user.starred.add(post._id)
  else:
    post.stars.remove(uid)
    user.starred.remove(post._id)
  post.save()
  user.save()
  return 'OK', 200, {'Content-Type': 'text/plain'}
开发者ID:r3t,项目名称:master-term1-webdev,代码行数:17,代码来源:funny.py

示例5: user_list_exercises

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def user_list_exercises(user_id):
	begin = 0
	length = 25
	try:
		if request.json != None:
			begin = int(request.json.get('begin', 0))
			length = int(request.json.get('length', 25))
	except:
		abort(403)
	try :
		user = User.get(user_id)
		if user == None:
			abort(404)
	except Exception:
		abort(404);
	exerciseList = user.getExerciseList(begin, length);
	if exerciseList == None:
		abort(400)
	return jsonify({
		'user': user_id,
		'exercises': exerciseList,
		'begin': begin,
		'length': length})
开发者ID:Ododo,项目名称:flask-api,代码行数:25,代码来源:main.py

示例6: get_user

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def get_user(user_id):
	""" Retrieves user <user_id> data """
	user = User.get(user_id)
	if user == None:
		abort(404)
	return jsonify({'user': user.output()})
开发者ID:Ododo,项目名称:flask-api,代码行数:8,代码来源:main.py

示例7: show_posts_starred

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
def show_posts_starred():
  # I think it's not a good idea to use such implementation.
  user = User.get(session.get('uid'))
  posts = [elem for elem in Post.view('posts/by_date') if elem._id in user.starred]
  return render_template('posts.html', posts = posts)
开发者ID:r3t,项目名称:master-term1-webdev,代码行数:7,代码来源:funny.py

示例8: get

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import get [as 别名]
 def get(self, *args, **kwargs):
     domains_list = DomainLogs.select().where(DomainLogs.user_id == self.current_user).order_by(
         DomainLogs.created_time.desc())
     user = User.get(User.id == self.current_user)
     self.render("list.html", domains_list=domains_list, user=user)
开发者ID:Nightsuki,项目名称:QvQDNS,代码行数:7,代码来源:list.py


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