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


Python validation.cast_integer函数代码示例

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


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

示例1: get_list

	def get_list(self, owner_userid, auth_userid, include_public_tags=0, order_by="tag_name", order_dir="asc"):
                """
                Returns a flat list of tags. Each item in the list is a dictionary. Each
                dictionary having the following elements:

                        - tag_name
                        - cnt_images

                @param browse_userid: browse_userid (the user to find tags for)
                @type browse_userid: Int

                @param auth_userid: auth_userid (the logged in user making the request)
                @type browse_userid: String

                @param include_public_tags: Whether to show only tags used by this user, or everyone's tags on his photos
                @type include_public_tags: Boolean

                @param order_by: One of ('tag_name', 'cnt_images')
                @type order_by: String

                @param order_dir: One of ('asc', 'desc')
                @type order_dir: String

                @return: List of tags
                @rtype: List
                """
                try:
                        owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
                        if auth_userid:
                                auth_userid = validation.cast_integer(auth_userid, 'auth_userid')
                        validation.oneof(order_by, ('tag_name', 'cnt_images'), 'order_by')
                        validation.oneof(order_dir, ('asc', 'desc'), 'order_dir')
                except errors.ValidationError, ex:
                        return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:34,代码来源:Tags.py

示例2: get_complete_list_with_relations_owner

	def get_complete_list_with_relations_owner(self, owner_userid, glob, limit, sort):
		"""
		Get *all* tags for owner_username's images and mark any that
		match the glob.

		@param owner_username: Owner of the account
		@type owner_username: String

		@param glob: A complex dictionary of limits for the user_images table
			see Glober.py for more details.
		@type glob: Dictionary
		"""
		valid_sorts = {
			'title-asc': ("t1.tag_name", "asc"),
			'title-desc': ("t1.tag_name", "desc"),
			'date_asc': ("date_added", "asc"),
			'date_desc': ("date_added", "desc"),
			'count-asc': ("cnt_images", "asc"),
			'count-desc': ("cnt_images", "desc"),
			'recent':("last_used", "desc")
		}
		try:
			owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
			validation.required(glob, 'glob')
			limit = validation.cast_integer(limit, 'limit')
			validation.oneof(sort, valid_sorts.keys(), 'sort')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:28,代码来源:Tags.py

示例3: get_contact_groups

	def get_contact_groups(self, member_userid, glob, limit, offset):
		"""
		Get a list of contact groups

		@param member_username: User account to get info for.
		@type member_username: String

		@param glob: A dictionary of settings
		@type glob : Dict

		@param limit: Number of contact groups to return.
		@type limit: Integer

		@param offset: Offset with the group list.
		@type offset: Integer

		@return: List of contact groups
		@rtype: (Deferred) List
		"""
		try:
			member_userid = validation.cast_integer(member_userid, 'member_userid')
			limit = validation.cast_integer(limit, 'limit')
			offset = validation.cast_integer(offset, 'offset')
			validation.instanceof(glob, dict, 'glob')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:kkszysiu,项目名称:zoto-server,代码行数:26,代码来源:Contacts.py

示例4: get_render

    def get_render(self, image_id, width, height, crop):
        """
		Gets a render for an image.

		@param owner_username: User who owns the image
		@type owner_username: String

		@param media_id: ID of the image
		@type media_id: String

		@param width: Width of the render
		@type width: Integer

		@param height: Height of the render
		@type height: Integer

		@param crop: Whether or not the render is cropped
		@type crop: Boolean
		"""
        try:
            image_id = validation.cast_integer(image_id, "image_id")
            width = validation.cast_integer(width, "width")
            height = validation.cast_integer(height, "height")
            crop = validation.cast_boolean(crop, "crop")
        except errors.ValidationError, ex:
            return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:26,代码来源:MediaHost.py

示例5: share

	def share(self, owner_userid, recipients, sender_name, subject, message, album_ids):
		"""
		Sends an invite to the list of recipients, asking them to view the
		specified albums.

		@param owner_username: Owner of the albums
		@type owner_username: String

		@param recipients: List of recipients...each entry can be a contact list name, 
					a username, or an email address.
		@type recipients: List/Tuple

		@param subject: Subject of the invite email
		@type subject: String

		@param message: Actual text of the email
		@type message: String

		@param album_ids: List of album id's
		@type album_ids: List/Tuple
		"""
		try:
			if not isinstance(recipients, (list, tuple)):
				recipients = [recipients]
			if not isinstance(album_ids, (list, tuple)):
				album_ids = [album_ids]
			owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
			subject = validation.string(subject)
			message = validation.string(message)
			temp_ids = []
			for album_id in album_ids:
				temp_ids.append(validation.cast_integer(album_id, 'album_id'))
			album_ids = temp_ids
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:35,代码来源:Albums.py

示例6: set_image_permission

	def set_image_permission(self, owner_userid, image_id, perm_type, flag, groups):
		"""
		Sets the flag and groups for a specific perm type (view, tag, etc)

		@param owner_userid: Userid of the user who owns the image
		@type owner_userid: Integer

		@param image_id: ID of the image
		@type media_id: Int

		@param perm_type: Permission being set
		@type perm_type: String

		@param flag: Permission value
		@type flag: Integer

		@param groups: (optional) groups to be added if flag = 2
		@type groups: List
		"""
		try:
			owner_userid = validation.cast_integer(owner_userid, "owner_userid")
			image_id = validation.cast_integer(image_id, 'image_id')
			validation.oneof(perm_type, ('view', 'tag', 'comment', 'print', 'download', 'geotag', 'vote', 'blog'), 'perm_type')
			flag = validation.cast_integer(flag, 'flag')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:26,代码来源:Permissions.py

示例7: delete

	def delete(self, owner_userid, image_ids):
		"""
		Deletes an image->user association (removes it from their account).  The
		binary image data still exists, however, as it may be owned by other users.

		@param owner_username: Username who owns the image.
		@type owner_username: String

		@param media_ids: Single media_id or a list of media_ids to be deleted.
		@type media_ids: String, or List/Tuple of strings.

		@return: deleted media IDs
		@rtype: List
		"""
		owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
		if not isinstance(image_ids, (list, tuple)):
			image_ids = [image_ids]

		real_ids = []
		for id in image_ids:
			real_ids.append(validation.cast_integer(id, 'id'))

		def img_delete_txn(txn, userid, ids):
			for id in ids:
				txn.execute("""
					select zoto_delete_user_image(%s, %s)
					""", (userid, id))
			return ids

		d = self.app.db.runInteraction(img_delete_txn, owner_userid, real_ids)
		d.addCallback(self.app.api.mediahost.delete_user_images)
		d.addCallback(lambda _: (0, '%d images deleted' % len(real_ids)))
		d.addErrback(lambda _: (-1, _.getErrorMessage()))
		return d
开发者ID:kkszysiu,项目名称:zoto-server,代码行数:34,代码来源:Images.py

示例8: send_message

	def send_message(self, from_userid, to_userids, subject, body, reply_to_id):
		"""
		Sends a message to 1 or more recipients.

		@param from_username: User sending the message.
		@type from_username: String

		@param to_usernames: List of recipients
		@type to_usernames: List

		@param subject: Subject/heading of the message
		@type subject: String

		@param body: Body of the message
		@type body: String

		@param reply_to_id: Message being replied to, if applicable
		@type reply_to_id: Integer
		"""
		try:
			from_userid = validation.cast_integer(from_userid, 'from_userid')
			subject = validation.string(subject)
			validation.required(subject, 'subject')
			body = validation.string(body)
			validation.required(body, 'body')
			reply_to_id = validation.cast_integer(reply_to_id, 'reply_to_id')
			recipients = []
			if not isinstance(to_userids, (list, tuple)):
				to_userids = [to_userids]
			for user in to_userids:
				recipients.append(validation.cast_integer(user, 'to_userid'))
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:33,代码来源:Messages.py

示例9: get_images

	def get_images(self, album_id, auth_userid, glob, limit, offset):
		"""
		Gets a list of the images in an album, with optional limit/offset.

		@param album_id: Album to get images for.
		@type album_id: Integer

		@param auth_username: Logged in user
		@type auth_username: String

		@param limit: Number of images to get
		@type limit: Integer

		@param offset: Offset within the album to start getting images
		@type offset: Integer
		"""
		try:
			album_id = validation.cast_integer(album_id, 'album_id')
			if auth_userid:
				auth_userid = validation.cast_integer(auth_userid, 'auth_userid')
			limit = validation.cast_integer(limit, 'limit')
			offset = validation.cast_integer(offset, 'offset')
			validation.instanceof(glob, dict, 'glob')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:25,代码来源:Albums.py

示例10: get_outbox

	def get_outbox(self, owner_userid, glob, limit, offset):
		"""
		Gets a list of a user's sent messages.

		@param owner_username: User to get messages for.
		@type owner_username: String

		@param glob: Dictionary of options (count_only, order_by, order_dir)
		@type glob: Dictionary

		@param limit: Maximum number of messages to return
		@type limit: Integer

		@param offset: Position to start returning messages
		@type offset: Integer
		"""
		try:
			owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
			if glob.has_key('order_by'):
				validation.oneof(glob['order_by'], ('message_id', 'to_username', 'subject', 'body', 'status', 'date_updated'), 'order_by')
			if glob.has_key('order_dir'):
				validation.oneof(glob['order_dir'], ('asc', 'desc'), 'order_dir')
			limit = validation.cast_integer(limit, 'limit')
			offset = validation.cast_integer(offset, 'offset')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:26,代码来源:Messages.py

示例11: add_rendered

    def add_rendered(self, image_id, data, width, height, crop):
        """
		Adds a rendered image to the filesystem.

		@param media_id: ID of the image being rendered.
		@type media_id: String

		@param owner_username: User who's account the image is being rendered for.
		@type owner_username: String

		@param data: Actual binary data of the render
		@type data: String

		@param width: Requested width
		@type width: Integer

		@param height: Requested height
		@type height: Integer

		@param crop: Whether or not the image was cropped
		@type crop: Boolean
		"""
        try:
            image_id = validation.cast_integer(image_id, "image_id")
            validation.required(data, "data")
            if width:
                width = validation.cast_integer(width, "width")
                height = validation.cast_integer(height, "height")
                crop = validation.cast_boolean(crop, "crop")
        except errors.ValidationError, ex:
            return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:31,代码来源:MediaHost.py

示例12: _make_media_path

    def _make_media_path(self, media_id, host, username=None, width=None, height=None, crop=None):
        """
		Makes a path to an image.

		@param media_id: ID of the image
		@type media_id: String

		@param host: Host that holds the image
		@type host: String

		@param username: User who modified the image (if applicable)
		@type username: String

		@param width: Width of the render
		@type width: Integer

		@param height: Height of the render
		@type height: Integer

		@param crop: Whether or not the render is cropped
		@type crop: Integer
		"""
        try:
            media_id = validation.media_id(media_id)
            validation.required(host, "host")
            if username:
                username = validation.username(username, "username")
            if width:
                width = validation.cast_integer(width, "width")
                height = validation.cast_integer(height, "height")
                crop = validation.cast_boolean(crop, "crop")
        except errors.ValidationError, ex:
            return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:33,代码来源:MediaHost.py

示例13: add_image_comment

	def add_image_comment(self, owner_userid, commenting_userid, image_id, subject, body, ip_address):
		"""
		Adds a comment to an image.

		@param owner_username: Username who owns the image being commented on.
		@type owner_username: String

		@param commenting_username: Username making the comment.
		@type commenting_username: String

		@param media_id: Image being commented on.
		@type media_id: String

		@param subject: Subject of the comment.
		@type subject: String

		@param body: Body of the comment.
		@type body: String

		@param ip_address: IP Address the comment is originating from
		@type ip_address: String

		@return: 0 on successful comment insertion, raises an exception otherwise.
		@rtype: Integer
		"""
		try:
			owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
			commenting_userid = validation.cast_integer(commenting_userid, 'commenting_userid')
			image_id = validation.cast_integer(image_id, "iamge_id")
			validation.required(body, 'body')
			validation.required(ip_address, 'ip_address')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:33,代码来源:Comments.py

示例14: update_image_comment

	def update_image_comment(self, comment_owner, comment_id, subject, body, ip_address):
		"""
		Adds a comment to an image.

		@param commenting_username: Username making the comment.
		@type commenting_username: String

		@param comment_id: Comment being edited on.
		@type comment_id: Integer

		@param subject: Subject of the comment.
		@type subject: String

		@param body: Body of the comment.
		@type body: String

		@param ip_address: IP Address the comment is originating from
		@type ip_address: String

		@return: 0 on successful comment insertion, raises an exception otherwise.
		@rtype: Integer
		"""
		try:
			comment_owner = validation.cast_integer(comment_owner, 'comment_owner')
			comment_id = validation.cast_integer(comment_id, 'comment_id')
			validation.required(body, 'body')
			validation.required(ip_address, 'ip_address')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:29,代码来源:Comments.py

示例15: _generate_rendered

	def _generate_rendered(self, data, image_id, width, height, crop, quality):
		"""
		Generates and stores a rendered copy of an image for a given user.

		@param media_id: ID of the image being rendered.
		@type media_id: String

		@param data: Raw binary data for the image.
		@type data: String

		@param owner_username: User the image is being rendered for.
		@type owner_username: String

		@param width: Requested width of the image.
		@type width: Integer

		@param height: Requested height of the image.
		@type height: Integer

		@param crop: Whether or not the image should be cropped to exact size.
		@type crop: Boolean

		@param quality: Quality to use for the render.
		@type quality: Integer

		@return: Rendered binary data.
		@rtype: String
		"""
		try:
			validation.required(data, 'data')
			image_id = validation.cast_integer(image_id, 'image_id')
			width = validation.cast_integer(width, 'width')
			height = validation.cast_integer(height, 'height')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
开发者ID:kkszysiu,项目名称:zoto-server,代码行数:35,代码来源:Images.py


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