本文整理汇总了Python中models.Post.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Post.gql方法的具体用法?Python Post.gql怎么用?Python Post.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.gql方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def user():
user = '[email protected]'
if user == None:
flash('User ' + nickname + ' not found.')
return redirect(url_for('index'))
posts = Post.gql('WHERE author = :1', user)
return render_template('user.html', user = user, posts = posts, users = users)
示例2: index
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def index(request):
query = Post.gql("ORDER BY date DESC")
form = PostForm()
c = _getClient()
logging.info(c.thumbnail("/a.jpg"))
return render_to_response(
"index.html", {"posts": query.fetch(20), "form": form}, context_instance=RequestContext(request)
)
示例3: index
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def index(request):
query = Post.gql('ORDER BY date DESC')
form = GuestbookForm()
return render_to_response('index.html',
{'posts': query.fetch(20),
'form': form
}
)
示例4: get_context_data
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def get_context_data(self, *args, **kwargs):
ctx = super(PostArchive, self).get_context_data(*args, **kwargs)
page = self.request.GET.get('p', 1)
year = self.kwargs.get('year', None)
month = self.kwargs.get('month', None)
day = self.kwargs.get('day', None)
msg = ""
try:
if day and month and year:
lower_limit = date(int(year), int(month), int(day))
upper_limit = lower_limit + relativedelta(days=+1)
msg = "%s" % datefilter(lower_limit, "jS M Y")
elif month and year:
lower_limit = date(int(year), int(month), 1)
upper_limit = lower_limit + relativedelta(months=+1)
msg = "%s" % datefilter(lower_limit, "F Y")
elif year:
lower_limit = date(int(year), 1, 1)
upper_limit = lower_limit + relativedelta(years=+1)
msg = "%s" % year
except ValueError:
raise Http404
if self.request.user.is_authenticated():
gql = "WHERE post_date >= :1 AND post_date <= :2 ORDER BY post_date DESC"
else:
gql = "WHERE is_published = true AND post_date >= :1 AND post_date <= :2 ORDER BY post_date DESC"
objects = Post.gql(gql, lower_limit, upper_limit)
pager = Paginator(objects, PAGE_SIZE)
page_obj = pager.page(page)
ctx.update({
'display_message': msg,
'paginator': pager,
'page_obj': page_obj,
'year': year,
'month': month,
'day': day
})
return ctx
示例5: index
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def index(request):
query = Post.gql("ORDER BY date DESC")
form = ReviewForm()
return render_to_response("index.html", {"posts": query.fetch(20), "form": form})
示例6: index
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def index(request):
query = Post.gql('ORDER BY date DESC')
form = PostForm()
return render_to_response('index.html',
{'posts': query.fetch(20), 'form': form},
context_instance=RequestContext(request))
示例7: osdetail
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def osdetail(request, book_id):
q = Post.gql('WHERE osys IN (\'%s\')' % book_id)
return render_to_response('getbybook.html', {'posts': q.fetch(100)
}
)
示例8: listall
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import gql [as 别名]
def listall(request):
query = Post.gql('ORDER BY created_on DESC')
return render_to_response('all.html',
{'posts': query.fetch(100)
}
)