當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。