• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python function.intval函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.function.intval函数的典型用法代码示例。如果您正苦于以下问题:Python intval函数的具体用法?Python intval怎么用?Python intval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了intval函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:0ps,项目名称:Minos,代码行数:34,代码来源:publish.py


示例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)
开发者ID:yaoml,项目名称:Minos,代码行数:58,代码来源:publish.py


示例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)
开发者ID:yangxue088,项目名称:Minos,代码行数:33,代码来源:amazon.py


示例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")
开发者ID:resec,项目名称:superhero,代码行数:16,代码来源:user.py


示例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)
开发者ID:resec,项目名称:superhero,代码行数:9,代码来源:dashboard.py


示例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)
开发者ID:happyAnger6,项目名称:80h_tornado,代码行数:9,代码来源:dashboard.py


示例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)
开发者ID:lukw00,项目名称:Minos,代码行数:9,代码来源:dashboard.py


示例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)
开发者ID:resec,项目名称:superhero,代码行数:11,代码来源:user.py


示例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)
开发者ID:404soul,项目名称:Minos,代码行数:11,代码来源:main.py


示例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)
开发者ID:0ps,项目名称:Minos,代码行数:12,代码来源:open.py


示例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")
开发者ID:happyAnger6,项目名称:myBlog,代码行数:12,代码来源:admin.py


示例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)
开发者ID:resec,项目名称:superhero,代码行数:12,代码来源:user.py


示例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")
开发者ID:happyAnger6,项目名称:myBlog,代码行数:23,代码来源:admin.py


示例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'])
开发者ID:happyAnger6,项目名称:myBlog,代码行数:23,代码来源:admin.py


示例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)
开发者ID:yangxue088,项目名称:Minos,代码行数:14,代码来源:main.py


示例16: get

	def get(self, *args, **kwargs):
		limit = 20
		page = intval(args[1])
		if not page or page <= 0 : page = 1
		cursor = self.db.message.find({
			"$or": [
				{"to": self.current_user["username"]},
				{"from": self.current_user["username"]}
			]
		})
		count = yield cursor.count()
		cursor.sort([('time', pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
		messages = yield cursor.to_list(length = limit)
		self.render("message.htm", messages = messages, count = count, cutstr = cutstr)
开发者ID:404soul,项目名称:Minos,代码行数:14,代码来源:message.py


示例17: get

 def get(self, *args, **kwargs):
     sortid = args[0]
     limit = 15
     page = intval(args[2])
     if not page or page <= 0:
         page = 1
     sort = yield self.db.sort.find_one({"_id": ObjectId(sortid)})
     if not sort:
         self.custom_error("板块不存在")
     cursor = self.db.article.find({"sort._id": ObjectId(sortid)})
     count = yield cursor.count()
     cursor.sort([("time", pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
     posts = yield cursor.to_list(length=limit)
     self.render("sort.htm", posts=posts, page=page, sort=sort, time_span=time_span, count=count, each=limit)
开发者ID:lukw00,项目名称:Minos,代码行数:14,代码来源:sort.py


示例18: editgame_action

	def editgame_action(self, *args, **kwargs): #修改一个已经存在的游戏
		id = self.get_body_argument("id")
		game = dict(
			path = self.get_body_argument("path"),
			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")),
			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")),
		)
		model = GameModel()
		if not model(game):
			self.custom_error(model.error_msg)
		game = yield self.db.games.find_and_modify({
			"_id": ObjectId(id)
		}, {
			"$set": game
		})
		self.redirect("/manage/gamedetail/%s" % game['_id'])
开发者ID:happyAnger6,项目名称:myBlog,代码行数:24,代码来源:admin.py


示例19: _view_user

	def _view_user(self, arg):
		username = self.get_query_argument("username", default=None)
		where = {"username": {"$regex": ".*"+re.escape(username)+".*"}} if username else {}
		limit = 15
		page = intval(arg)
		page = page if page > 1 else 1
		user = self.db.member.find(where)
		count = yield user.count()
		user.tag([('time', pymongo.ASCENDING)]).limit(limit).skip((page - 1) * limit)
		users = yield user.to_list(limit)
		if username:
			search = "?username=%s" % username
		else:
			search = ""
		self.render("userlist.html", page = page, users = users, count = count, each = limit, search = search)
开发者ID:resec,项目名称:superhero,代码行数:15,代码来源:dashboard.py


示例20: _view_invite

 def _view_invite(self, arg):
     where = self.get_query_argument("act", default=None)
     act = {
         "nouse": {"used": False},
         "used": {"used": True},
         "expire": {"time": {"$lt": time.time() - self.settings["invite_expire"]}, "used": False},
     }
     where = act.get(where) if (where in act) else {}
     limit = 15
     page = intval(arg)
     page = page if page > 1 else 1
     cursor = self.db.invite.find(where)
     count = yield cursor.count()
     cursor.sort([("time", pymongo.DESCENDING)]).limit(limit).skip((page - 1) * limit)
     invites = yield cursor.to_list(limit)
     self.render("invite.htm", invites=invites, count=count, each=limit, page=page)
开发者ID:lukw00,项目名称:Minos,代码行数:16,代码来源:dashboard.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python functions.trace函数代码示例发布时间:2022-05-26
下一篇:
Python full.matrix函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap