本文整理汇总了Python中util.function.intval函数的典型用法代码示例。如果您正苦于以下问题:Python intval函数的具体用法?Python intval怎么用?Python intval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了intval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
def post(self, *args, **kwargs):
id = self.get_body_argument("id", default=None)
if not id:
self.custom_error("不存在这篇文章", "", id)
post = yield self.db.article.find_one({
"_id": ObjectId(id)
})
self.__check_power(post)
content = self.get_body_argument("ckeditor", default=None)
post["title"] = self.get_body_argument("title", default=None)
sort = self.get_body_argument("sort", default=None)
post["charge"] = intval(self.get_body_argument("charge", default=0))
post["freebegin"] = intval(self.get_body_argument("freebegin", default=0))
post["freeend"] = intval(self.get_body_argument("freeend", default=0))
if post["charge"] < 0:
self.custom_error("收费不能低于0", content, id)
if post["freebegin"] > post["freeend"]:
self.custom_error("结束时间不能小于开始时间", content, id)
if not sort:
self.custom_error("不存在这个分类", content, id)
post["sort"] = yield self.db.sort.find_one({"_id": ObjectId(sort)})
if not post["sort"]:
self.custom_error("不存在这个分类", content, id)
# filter html
post["content"] = xss_filter(content)
model = ArticleModel()
if not model(post):
self.custom_error(model.error_msg, content, id)
yield self.db.article.find_and_modify({
"_id": post["_id"]
}, post)
self.redirect("/post/%s" % id)
示例2: post
def post(self, *args, **kwargs):
content = self.get_body_argument("ckeditor", default=None)
title = self.get_body_argument("title", default=None)
sort = self.get_body_argument("sort", default=None)
charge = intval(self.get_body_argument("charge", default=0))
freebegin = intval(self.get_body_argument("freebegin", default=0))
freeend = intval(self.get_body_argument("freeend", default=0))
if not title:
self.flash["article"] = content
self.custom_error("标题不能为空哦", jump="/publish")
if charge < 0:
self.flash["article"] = content
self.custom_error("收费不能低于0", jump="/publish")
if freebegin > freeend:
self.flash["article"] = content
self.custom_error("结束时间不能小于开始时间", jump="/publish")
if not sort:
self.flash["article"] = content
self.custom_error("不存在这个分类", jump="/publish")
tosort = yield self.db.sort.find_and_modify({
"_id": ObjectId(sort)
}, {
"$inc": {"article": 1}
})
if not tosort:
self.flash["article"] = content
self.custom_error("不存在这个分类", jump="/publish")
# filter html
content = xss_filter(content)
article = {
"title": title,
"content": content,
"user": self.current_user["username"],
"sort": tosort,
"view": 0,
"like": [],
"unlike": [],
"charge": charge,
"time": time.time(),
"freebegin": freebegin,
"freeend": freeend,
"buyer": [],
"thanks": [],
"star": False,
"rank": 0,
"comment": [],
"open": False,
"top": False,
"lastcomment": time.time()
}
model = ArticleModel()
if not model(article):
self.flash["article"] = content
self.custom_error(model.error_msg, jump="/publish")
id = yield self.db.article.insert(article)
self.redirect("/post/%s" % id)
示例3: detail_page
def detail_page(self, arg):
site = arg.split('/')[0]
asin = arg.split('/')[1]
limit = 20
page = intval(self.get_argument("page", default=1))
if not page or page <= 0:
page = 1
product_cursor = self.db.follow_product.find({
"$and": [
{'username': self.get_current_user()['username']},
{'site': site},
{'asin': asin},
]})
products = yield product_cursor.to_list(1)
image = products[0]['image']
cursor = self.db.follow_monitor.find({
"$and": [
{'site': site},
{'asin': asin},
]})
count = yield cursor.count()
cursor.sort([('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
monitors = yield cursor.to_list(length=limit)
for monitor in monitors:
monitor['follows'] = json.loads(monitor['follows'])
monitor['time'] = monitor['time'].strftime("%Y-%m-%d %H:%M:%S")
self.render("amazon/follow_detail.htm", image=image, site=site, asin=asin, monitors=monitors, page=page,
each=limit, count=count)
示例4: _post_message
def _post_message(self):
openwebsite = intval(self.get_body_argument("openwebsite", default=1))
openqq = intval(self.get_body_argument("openqq", default=1))
openemail = intval(self.get_body_argument("openemail", default=1))
allowemail = intval(self.get_body_argument("allowemail", default=1))
yield self.db.member.find_and_modify({
"username": self.current_user["username"]
}, {
"$set": {
"openwebsite": openwebsite,
"openqq": openqq,
"openemail": openemail,
"allowemail": allowemail
}
})
self.redirect("/user/edit")
示例5: _view_tag
def _view_tag(self, arg):
limit = 15
page = intval(arg)
page = page if page > 1 else 1
cursor = self.db.tag.find()
count = yield cursor.count()
cursor.limit(limit).skip((page - 1) * limit)
tags = yield cursor.to_list(limit)
self.render("tag.html", tags = tags, count = count, each = limit, page = page)
示例6: _view_games
def _view_games(self, arg): #查看所有游戏
limit = 15
page = intval(arg)
page = page if page > 1 else 1
cursor = self.db.games.find()
count = yield cursor.count()
cursor.limit(limit).skip((page - 1) * limit)
games = yield cursor.to_list(limit)
self.render("games.htm", games = games, count = count, each = limit, page = page)
示例7: _view_sort
def _view_sort(self, arg):
limit = 15
page = intval(arg)
page = page if page > 1 else 1
cursor = self.db.sort.find()
count = yield cursor.count()
cursor.limit(limit).skip((page - 1) * limit)
sorts = yield cursor.to_list(limit)
self.render("sort.htm", sorts=sorts, count=count, each=limit, page=page)
示例8: like_act
def like_act(self, arg):
limit = 10
page = intval(arg)
if page <= 0 : page = 1
cursor = self.db.article.find({
"like": self.current_user["username"]
})
count = yield cursor.count()
cursor.tag([('_id', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
posts = yield cursor.to_list(length = limit)
self.render("like.html", posts = posts, page = page, count = count, each = limit)
示例9: get
def get(self, *args, **kwargs):
limit = 15
page = intval(args[1])
if not page or page <= 0 : page = 1
cursor = self.db.article.find()
cursor.sort([('top', pymongo.DESCENDING), ("lastcomment", pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
count = yield cursor.count()
posts = yield cursor.to_list(length = limit)
sorts = yield self.get_sort()
self.render("main.htm", posts = posts, sorts = sorts, page = page,
time_span = time_span, count = count, each = limit)
示例10: get
def get(self, *args, **kwargs):
limit = 15
page = intval(args[1])
if not page or page <= 0 : page = 1
cursor = self.db.article.find({
"open": True
})
cursor.sort([("top", pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
count = yield cursor.count()
posts = yield cursor.to_list(length = limit)
self.render("open_list.htm", posts = posts, page = page,
time_span = time_span, count = count, each = limit)
示例11: newsort_action
def newsort_action(self, *args, **kwargs):
sort = dict(
name = self.get_body_argument("name"),
intro = self.get_body_argument("intro",default=None),
show = True if intval(self.get_body_argument("show", default=None)) else False,
article = 0
)
model = SortModel()
if not model(sort):
self.custom_error(model.error_msg)
sort = yield self.db.sort.insert(sort)
self.redirect("/manage/sort")
示例12: bookmark_act
def bookmark_act(self, arg):
limit = 10
page = intval(arg)
if page <= 0 : page = 1
user = yield self.db.member.find_one({
"username": self.current_user["username"]
})
bookmark = user.get("bookmark")
count = len(bookmark)
bookmark = bookmark[(page - 1) * limit:(page - 1) * limit + limit]
bookmark.reverse()
self.render("bookmark.html", bookmark = bookmark, page = page, count = count, each = limit)
示例13: newgame_action
def newgame_action(self, *args, **kwargs):#创建一个新的游戏
game = dict(
name = self.get_body_argument("name"),
type = intval(self.get_body_argument("type")),
play_type = intval(self.get_body_argument("play_type")),
resource_type = intval(self.get_body_argument("resource_type")),
path = self.get_body_argument("path"),
question = self.get_body_argument("question"),
answer1 = self.get_body_argument("answer1"),
answer2 = self.get_body_argument("answer2"),
answer3 = self.get_body_argument("answer3"),
answer4 = self.get_body_argument("answer4"),
right_answer = self.get_body_argument("right_answer"),
switch = intval(self.get_body_argument("switch")),
plays = 0,
right_plays = 0,
wrong_plays = 0
)
model = GameModel()
if not model(game):
self.custom_error(model.error_msg)
sort = yield self.db.games.insert(game)
self.redirect("/manage/games")
示例14: edituser_action
def edituser_action(self, *args, **kwargs):
id = self.get_body_argument("id")
user = dict(
money = intval(self.get_body_argument("money")),
power = intval(self.get_body_argument("power")),
email = self.get_body_argument("email"),
website = self.get_body_argument("website"),
qq = self.get_body_argument("qq"),
address = self.get_body_argument("address"),
signal = self.get_body_argument("signal"),
)
model = UserModel()
if not model(user):
self.custom_error(model.error_msg)
password = self.get_body_argument("password", default=None)
if password:
user["password"] = yield self.backend.submit(hash.get, password)
user = yield self.db.member.find_and_modify({
"_id": ObjectId(id)
}, {
"$set": user
})
self.redirect("/manage/userdetail/%s" % user['username'])
示例15: get
def get(self, *args, **kwargs):
limit = 15
page = intval(args[1])
if not page or page <= 0: page = 1
cursor = self.db.article.find({'$or': [{'private': None}, {'private': 'off'}]})
cursor.sort(
[('top', pymongo.DESCENDING), ("lastcomment", pymongo.DESCENDING), ('time', pymongo.DESCENDING)]).limit(
limit).skip((page - 1) * limit)
count = yield cursor.count()
posts = yield cursor.to_list(length=limit)
sorts = yield self.get_sort()
self.render("main.htm", posts=filter(lambda post: post.get('private', 'off') == 'off', posts), sorts=sorts, page=page,
time_span=time_span, count=count, each=limit)