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


Python Comment.findAll方法代码示例

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


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

示例1: authenticate

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def authenticate(*,email,passwd):
	if not email:
		raise APIValueError('email','Invalid email')
	if not passwd:
		raise APIValueError('passwd','Invalid passwd')
	users = await User.findAll('email=?',[email])
	if len(users) == 0:
		raise APIValueError('email','Email not exist.')
	user = users[0]
	# check passwd
	sha1 = hashlib.sha1()
	sha1.update(user.id.encode('utf-8'))
	sha1.update(b':')
	sha1.update(passwd.encode('utf-8'))
	if user.passwd != sha1.hexdigest():
		raise APIValueError('passwd','passwd error')
	# authenticate ok set cookie
	r = web.Response()
	r.set_cookie(COOKIE_NAME,user2cookie(user,86400),max_age=86400,httponly=True)
	user.passwd = '******'
	r.content_type = 'application/json'
	r.body = json.dumps(user,ensure_ascii=False).encode('utf-8')
	return r

# ?? 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:27,代码来源:handlers.py

示例2: index

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def index(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.findNumber('count(id)')
    page = Page(num, page_index)
    if num == 0:
        blogs = []
    else:
        blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(page.offset, page.limit))
    # ?????????????????????
    # app.py?response_factory???handler.py??????????
    return {
        '__template__': 'blogs.html',
        'page': page,
        'blogs': blogs
    }


# day11??
# ???????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:21,代码来源:handlers.py

示例3: get_blog

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id, request):
    blog = yield from Blog.find(id)  # ??id???????????
    # ????????blog??????????????????????
    comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
    # ?????????html??
    for c in comments:
        c.html_content = text2html(c.content)
    # blog??markdown????????html??
    blog.html_content = markdown2.markdown(blog.content)
    return {
        '__template__': 'blog.html',
        'blog': blog,
          '__user__':request.__user__,
        'comments': comments
    }


# day10???
# ??????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:21,代码来源:handlers.py

示例4: api_get_users

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_get_users():
    users = await User.findAll(orderBy="created_at desc")
    for u in users:
        u.passwd = "*****"
    # ?dict????,?????__template__,??app.py?response factory???json
    return dict(users=users)

# API:????
# ?register.html?????/api/users??
# ???????????
# ???_RE_EMAIL??????
# ^??????
# [a-z0-9\.\_]+??????????????.?-?_
# \@[email protected]
# [a-z0-9\-\_]+??????????????-?_????.?
# (\.[a-z0-9\-\_]+){1,4}???????????????????????????.??????????-?_
# $?????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:19,代码来源:handlers.py

示例5: authenticate

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def authenticate(*, email, passwd):
    if not email:
        raise APIValueError('email', 'Invalid email.')
    if not passwd:
        raise APIValueError('passwd', 'Invalid password.')
    users = yield from User.findAll('email=?', [email])
    if len(users) == 0:
        raise APIValueError('email', 'Email not exist.')
    user = users[0]
    # check passwd:
    sha1 = hashlib.sha1()
    sha1.update(user.id.encode('utf-8'))
    sha1.update(b':')
    sha1.update(passwd.encode('utf-8'))
    if user.passwd != sha1.hexdigest():
        raise APIValueError('passwd', 'Invalid password.')
    # authenticate ok, set cookie:
    r = web.Response()
    r.set_cookie(COOKIE_NAME, user2cookie(user, 86400), max_age=86400, httponly=True)
    user.passwd = '******'
    r.content_type = 'application/json'
    r.body = json.dumps(user, ensure_ascii=False).encode('utf-8')
    return r 
开发者ID:xsingHu,项目名称:xs-python-architecture,代码行数:25,代码来源:handlers.py

示例6: index

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def index(request,*,page='1'):
	page_index = get_page_index(page)
	num = await Blog.findNumber('count(id)')
	page = Page(num,page_index)
	if page == 0:
		blogs = []
	else:
		blogs = await Blog.findAll(orderBy = 'created_at desc',limit=(page.offset,page.limit))
	return{
		'__template__' : 'blogs.html',
		'page' : page,
		'blogs' : blogs,
		'__user__' : request.__user__
	} 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:16,代码来源:handlers.py

示例7: get_blog

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id,request):
	blog = await Blog.find(id)
	comments = await Comment.findAll('blog_id=?',[id],orderBy='created_at desc')
	for c in comments:
		c.html_content = text2html(c.content)
	blog.html_content = markdown2.markdown(blog.content)
	return	{
		'__template__' : 'blog.html',
		'blog' : blog,
		'comments' : comments,
		'__user__' : request.__user__
	}

# ???? 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:16,代码来源:handlers.py

示例8: api_comments

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_comments(*,page='1'):
	page_index = get_page_index(page)
	num = await Comment.findNumber('count(id)')
	p = Page(num,page_index)
	if num == 0:
		return dict(page=p,comments=())
	comments = await Comment.findAll(orderBy='created_at desc',limit=(p.offset,p.limit))
	return dict(page=p,comments=comments) 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:10,代码来源:handlers.py

示例9: api_get_users

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_get_users(*,page='1'):
	page_index = get_page_index(page)
	num = await User.findNumber('count(id)')
	p = Page(num,page_index)
	if num ==0 :
		return dict(page=p,users=())
	users = await User.findAll(orderBy='created_at desc',limit=(p.offset,p.limit))
	for u in users:
		u.passwd = '******'
	return dict(page=p,users=users) 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:12,代码来源:handlers.py

示例10: api_blogs

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_blogs(*,page='1'):
	page_index = get_page_index(page)
	num = await Blog.findNumber('count(id)')
	p = Page(num,page_index)
	if num == 0:
		return dict(page=0,blogs={})
	blogs = await Blog.findAll(orderBy='created_at desc',limit=(p.offset,p.limit))
	return dict(page=p,blogs=blogs) 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:10,代码来源:handlers.py

示例11: authenticate

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def authenticate(*, email, passwd):  # ???????????
    # ????????????
    if not email:
        raise APIValueError('email', 'Invalid email.')
    if not passwd:
        raise APIValueError('passwd', 'Invalid password.')
    # ???????email???list?????
    users = yield from User.findAll('email=?', [email])
    # ??list???0??????????????????????
    if len(users) == 0:
        raise APIValueError('email', 'Email not exist.')
    user = users[0] # ??????.???,?????????,???????list
    # ????:
    # ????????????????,????????
    # ????????????????????,???????????????,?????????
    # ???????????:sha1 = hashlib.sha1((user.id+":"+passwd).encode("utf-8"))
    # ???????????????(?api_register_user),??????
    sha1 = hashlib.sha1()
    sha1.update(user.id.encode('utf-8'))
    sha1.update(b':')
    sha1.update(passwd.encode('utf-8'))
    if user.passwd != sha1.hexdigest():
        raise APIValueError('passwd', 'Invalid password.')
    # ???????????cookie:
    # ?????????????
    r = web.Response()
    r.set_cookie(COOKIE_NAME, user2cookie(user, 86400), max_age=86400, httponly=True)
    user.passwd = '******'
    r.content_type = 'application/json'
    r.body = json.dumps(user, ensure_ascii=False).encode('utf-8')
    return r

# ?????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:35,代码来源:handlers.py

示例12: api_comments

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_comments(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Comment.findNumber('count(id)')  # num?????
    p = Page(num, page_index)  # ??Page?????????
    if num == 0:
        return dict(page=p, comments=())  # ???????????????app.py?response??????
    # ??????0,??????????
    # limit??select??????????,?????????,?????????????
    comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, comments=comments)

# day14??
# API????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:15,代码来源:handlers.py

示例13: index

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def index(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.findNumber('count(id)')
    page = Page(num)
    if num == 0:
        blogs = []
    else:
        blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(page.offset, page.limit))
    return {
        '__template__': 'blogs.html',
        'page': page,
        'blogs': blogs
    } 
开发者ID:xsingHu,项目名称:xs-python-architecture,代码行数:15,代码来源:handlers.py

示例14: get_blog

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def get_blog(id):
    blog = yield from Blog.find(id)
    comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
    for c in comments:
        c.html_content = text2html(c.content)
    blog.html_content = markdown2.markdown(blog.content)
    return {
        '__template__': 'blog.html',
        'blog': blog,
        'comments': comments
    } 
开发者ID:xsingHu,项目名称:xs-python-architecture,代码行数:13,代码来源:handlers.py

示例15: api_comments

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import findAll [as 别名]
def api_comments(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Comment.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, comments=())
    comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, comments=comments) 
开发者ID:xsingHu,项目名称:xs-python-architecture,代码行数:10,代码来源:handlers.py


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