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


Python Photo.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def post(self):
        if self.get_uploads('image'):
            upload_files = self.get_uploads('image')
            blob_info = upload_files[0]
            
        else:
            blob_info=None
            
        if self.form.validate():
            form=self.form
            photo=Photo(name=form.name.data,
            image=blob_info
            )
            
            if (form.lat.data and form.lon.data):
                photo.location=db.GeoPt(lat=form.lat.data,lon= form.lon.data)
            
            photo.put()
            response = redirect_to('collector-thanks',)
            
        else:
			form=self.form
			photo=Photo(name=form.name.data,
			email=form.email.data,
			phone=form.phone.data,
			image=blob_info
			)

			photo.put()
			response = redirect_to('collector',photo=photo.key())
            
            
        # Clear the response body.
        response.data = ''
        return response
开发者ID:rosskarchner,项目名称:colvinrunmill,代码行数:37,代码来源:handlers.py

示例2: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
	def post(self):
		try:
			upload = self.get_uploads('file')
			blob = upload[0]
			description = self.request.get('description');
			title = self.request.get('title');
			photo = Photo(blobKey=str(blob.key()), description=description, title=title)
			photo.put()
			competition = Competition(photoKey=photo.key(), dateCreated=datetime.datetime.now())
			competition.put();
			self.redirect("/competitions/latest")
		except:
			self.redirect("/upload-failure")
开发者ID:paulcarvill,项目名称:caption-competition,代码行数:15,代码来源:main.py

示例3: get_photo

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def get_photo(self):
        if "photo" not in self.request.POST:
            logging.debug("no image uploaded for new item!")
            return None
        try:
            img = self.request.POST.get("photo")
            img_name = img.filename
            img_data = img.file.read()
            img = images.Image(img_data)

            img.im_feeling_lucky()
            img.resize(640, 480)
            png_data = img.execute_transforms(images.PNG)

            img.resize(200, 140)
            thumb = img.execute_transforms(images.PNG)

            photo = Photo(name=img_name, image=png_data, thumb=thumb)
            return photo.put()
        except images.BadImageError:
            self.error(400)
            self.response.out.write("Sorry, we had a problem processing the image provided.")
        except images.NotImageError:
            self.error(400)
            self.response.out.write(
                "Sorry, we don't recognize that image format."
                "We can process JPEG, GIF, PNG, BMP, TIFF, and ICO files."
            )
        except images.LargeImageError:
            self.error(400)
            self.response.out.write("Sorry, the image provided was too large for us to process.")
开发者ID:tchaikov,项目名称:beanfs,代码行数:33,代码来源:item.py

示例4: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def post(self):
        """operacje na moich zdjeciach"""

        if self.request.get("media_id") == None:
            logging.info("no media id")
            return self.response.out.write("Error")

        try:
            media_id = int(self.request.get("media_id"))
        except ValueError:
            logging.error("%s is not valid instagram_id" % self.request.get("media_id"))
            return

        if self.request.get("type") == "activate":
            p = Photo().get_by_instagram_id(media_id)
            if p is not None:
                p.is_active = True
                p.is_user_active = True
                p.put()
            # logging.info('activated %s' % media_id)
            else:
                taskqueue.add(
                    url="/api/instagram/",
                    params={
                        "type": "add_instadaily_tag",
                        "media_id": media_id,
                        "user": self.user.name,
                        "token": self.user.token,
                    },
                    queue_name="api",
                )

        elif self.request.get("type") == "deactivate":
            p = Photo().get_by_instagram_id(media_id)
            if p is not None:
                p.is_user_active = False
                p.put()
            # logging.info('deactivated %s' % media_id)
            else:
                logging.warning("cannot deactivate unavailable photo")

        else:
            logging.info("unregocognized type=%s" % self.request.get("type"))

        self.response.out.write("ok")
开发者ID:yezooz,项目名称:instadaily-backend-appengine,代码行数:47,代码来源:methods.py

示例5: upload

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
def upload():
    lightbox_id = int(request.form['lightboxId'])
    lightbox = Lightbox.get_by_id(lightbox_id)
    photos = []

    for file in request.files.getlist('file'):
        logger.debug('processing file name %s for lightbox id: %d' % (file.filename, lightbox_id))
        photo = Photo()
        photo.lightbox = lightbox
        image_data = file.read()
        photo.full_image = db.Blob(image_data)
        photo.thumbnail = db.Blob(images.resize(image_data, 180, 180))
        photo.owner = users.get_current_user()
        photo.name = file.filename
        photo.put()
        photos.append(photo.key().id())

    return jsonify(lightbox={"id": lightbox.key().id(), "photos": photos})
开发者ID:ashimali,项目名称:baltipic,代码行数:20,代码来源:main.py

示例6: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def post(self, *args):
        if self.request.get('shop'):
            shop = db.get(self.request.get('shop'))
        else:
            shop = None

        if self.request.get('key'):
            photo = db.get(self.request.get('key'))
        else:
            img = self.request.body_file.vars['image']
            photo = Photo(user = users.get_current_user(),
                          shop = shop,
                          title = self.request.get('title'),
                          image = self.request.get('image'),
                          mime_type = img.headers['content-type'],
                          filename = img.filename,
                          size = len(self.request.get('image')),
                          )
        photo.put()
        self.redirect('/photo')
开发者ID:takatoshiono,项目名称:chin-ma-ya.org,代码行数:22,代码来源:photo.py

示例7: writeToDB

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
def writeToDB(photo, nickname):
    newPhoto = Photo()
    newPhoto.owner = nickname
    newPhoto.photoid = photo.gphoto_id.text
    newPhoto.thumbnail = photo.media.thumbnail[2].url
    newPhoto.title = photo.title.text
    try:
        newPhoto.time = datetime.datetime.fromtimestamp(float(photo.exif.time.text) / 1e3)
    except:
        pass
    try:
        newPhoto.exposure = photo.exif.exposure.text
    except:
        pass
    try:
        newPhoto.focallength = photo.exif.focallength.text
    except:
        pass
    try:
        newPhoto.make = photo.exif.make.text
    except:
        pass
    try:
        newPhoto.fstop = photo.exif.fstop.text
    except:
        pass
    try:
        newPhoto.model = photo.exif.model.text
    except:
        pass
    try:
        newPhoto.flash = photo.exif.flash.text
    except:
        pass
    try:
        newPhoto.iso = photo.exif.iso.text
    except:
        pass
    # Add to db after retrieved
    newPhoto.put()
    
开发者ID:JimmyCDChen,项目名称:photoAlbum,代码行数:42,代码来源:tool.py

示例8: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def post(self, album_id):
        uploaded_files = self.get_uploads('photo')

        user = get_user()

        if user:
            album = Album.get_by_id(
                int(album_id),
                parent=DEFAULT_DOMAIN_KEY
            )

            photo = Photo(parent=album.key)
            photo.author = user.key
            photo.name = self.request.get('photo_name')
            photo.blob_info_key = uploaded_files[0].key()

            photo.put()

            self.redirect('/album/%s/view' % album.key.integer_id())
        else:
            self.response.write('You must be signed in with your google account to upload photos')
开发者ID:MichaelAquilina,项目名称:Photo-Nebula,代码行数:23,代码来源:photos.py

示例9: create_and_save_new_photo_with_thumb

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
def create_and_save_new_photo_with_thumb(user, file_content, description=u''):
    img = images.Image(file_content)
    
    anim = get_anim_type_for_photo_size(img.width, img.height)
    thumb_anim = anim.thumb_anim
    
    # img.resize()
    thumb_img = images.resize(file_content, thumb_anim.photo_width, thumb_anim.photo_height)
    # thumb_img = img.execute_transforms(output_encoding=images.JPEG)
    
    # raise Exception(db.Blob(img))
    # raise Exception('%s\n%s' % (dir(img), img.__dict__))
    photo_file = PhotoFile(
        blob=db.Blob(file_content)
    )
    photo_file.put()
    
    photo = Photo(
        file=photo_file,
        user=user,
        anim_type=anim,
        anim_frame_time=0.25,
        description=description
    )
    photo.set_denormalized_fields()
    photo.put()
    
    thumb_file = ThumbnailFile(
        blob=thumb_img
    )
    thumb_file.put()
    
    thumb = Thumbnail(
        file=thumb_file,
        photo=photo
    )
    thumb.set_denormalized_fields()
    thumb.put()
    
    return photo
开发者ID:heracek,项目名称:quadanimr,代码行数:42,代码来源:utils.py

示例10: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def post(self, id=None):
        if id:
            photo = Photo.gql("WHERE id = :1", id).get()
        else:
            photo = Photo(content_type="image/jpg")

        date_posted = utils.strptime_for_edit(self.request.get('date_posted'))

        photo.title = self.request.get('title')
        photo.id = get_photo_id(date_posted, self.request.get('slug'))
        photo.location = self.request.get('location')

        location_slug = utils.slug(photo.location)
        location = db.Query(PhotoLocation).filter("id = ", location_slug).get()
        if not location:
            location = PhotoLocation(id=location_slug, name=photo.location)
            location.put()
        photo.location_ref = location

        photo.categories = self.request.get('categories')

        photo.categories_ref = []
        for category_name in photo.categories.split(","):
            category_name = category_name.strip()
            category_slug = utils.slug(category_name)
            category = db.Query(PhotoCategory).filter("id = ", category_slug).get()
            if not category:
                category = PhotoCategory(id=category_slug, name=category_name)
                category.put()
            photo.categories_ref.append(category.key())

        photo.description = self.request.get('description')
        photo.date_posted = date_posted
        if self.request.get('file'):
            photo.file = db.Blob(self.request.get('file'))
            photo.thumbnail = images.resize(photo.file, 128, 128)

        photo.put()

        self.redirect(photo.get_url())
开发者ID:ibz,项目名称:nuages,代码行数:42,代码来源:admin.py

示例11: fetch_img

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def fetch_img(self, img_id):
        token = User().get_by_name("yezooz").access_token
        url = "https://api.instagram.com/v1/media/%s?access_token=%s" % (img_id, token)
        try:
            f = urlfetch.fetch(url)
            data = json.loads(f.content)
        except urlfetch.DownloadError:
            return

        if not data.has_key("data"):
            if data.has_key("meta") and data["meta"].get("error_message") == "invalid media id":
                p = Photo().get_by_instagram_id(img_id)
                p.points = 0
                p.total_score = 0
                p.is_blocked = True
                p.put()
                logging.info("Photo %s has been deleted" % img_id)
                return

            if data.has_key("meta") and data["meta"].get("error_type") == "APINotAllowedError":
                # just update
                p = Photo().get_by_instagram_id(img_id)
                p.put()
                logging.warning("APINotAllowedError - %s" % url)
                return

            logging.warning("No data in fetched url: %s" % url)
            return

        try:
            p = Photo().get_by_instagram_id(img_id)
            if p is None:
                return
            p.likes = data["data"]["likes"]["count"]
            p.tags = data["data"]["tags"]
            p.total_score = (p.likes + p.points) - p.dislikes
            p.put()
        except AttributeError:
            logging.warning("got no data? %s" % str(data))
            return
开发者ID:yezooz,项目名称:instadaily-backend-appengine,代码行数:42,代码来源:photo_update.py

示例12: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import put [as 别名]
    def post(self):
        user = User.get_by_key_name(self.current_user['id'])

        #  action upload a photo
        if self.request.get('action') == 'upload':

            fd = self.request.get('photo')
            # ext = fd.file.name.split('.')[-1].lower()

            cropped, img = crop_image(fd, 'post', False)
            photo_blob = Photo.create_blob(img)

            extension = 'jpg' # if cropped==True else ext
            photo = Photo(user=user, file=photo_blob, extension=extension, is_used=False)
            photo.put()

            self.response.headers['Content-Type'] = 'application/json'
            self.response.out.write(json.dumps({'success': True, 'photo': str(photo.key())}))

        # Action create Photo post
        if self.request.get('action') == 'boker_photo':

            ispop = self.request.get('pop') == '1'
            if ispop:
                self.template = 'boker_pop.html'

            explicitly_shared = self.request.get('explicit_share', False)
            if explicitly_shared == 'on': explicitly_shared = True

            photokey = self.request.get('photokey')
            desc = self.request.get('desc')

            photo = Photo.get(photokey)
            if photo and desc:
                # Save boker
                boker = Boker(user=user, photo=photo, description=desc)
                boker.put()
                # Set photo used
                photo.is_used = True
                photo.put()

                # Run task: Posting to page wall
                boker_url = "%s/boker/%s" % (settings.APP_DOMAIN, boker.key().id())
                user_access_token = self.current_user['access_token']

                deferred.defer(post_page_photo, boker_url, photokey, desc)
                deferred.defer(publish_upload_action, user_access_token, boker_url, explicitly_shared)

                boker_url = self.uri_for('boker_view', boker_id=boker.key().id())
                if ispop:
                    self.response.out.write(u'<script type="text/javascript">window.parent.window.location.href="%s";</script>' % boker_url);
                else:
                    self.redirect(boker_url)
            else:
                return self.render_response(self.template, {
                            'errors': 'Photo dan Ceritanya harus diisi.',
                            'photokey': photokey,
                            'desc': desc,
                            })

        # Action create Video Post
        if self.request.get('action') == 'boker_video':
            ispop = self.request.get('pop') == '1'
            if ispop:
                self.template = 'boker_video.html'

            explicitly_shared = self.request.get('explicit_share', False)
            if explicitly_shared == 'on': explicitly_shared = True

            video_url = self.request.get('video_url')
            video_id = self.request.get('video_id')
            video_source = self.request.get('video_source')
            desc = self.request.get('desc')

            if video_id and video_source and desc:
                boker = Boker(user=user, video_id=video_id, video_source=video_source, description=desc)
                boker.put()

                boker_url = "%s/boker/%s" % (settings.APP_DOMAIN, boker.key().id())
                user_access_token = self.current_user['access_token']

                # deferred.defer(post_page_video, boker_url, boker.description)
                deferred.defer(publish_posts_action, user_access_token, boker_url, False)

                boker_url = self.uri_for('boker_view', boker_id=boker.key().id())
                if ispop:
                    self.response.out.write(u'<script type="text/javascript">window.parent.window.location.href="%s";</script>' % boker_url);
                else:
                    self.redirect(boker_url)
            else:
                return self.render_response(self.template, {
                            'errors': 'Video dan Ceritanya harus diisi.',
                            'video_url': video_url,
                            'desc': desc,
                            })
开发者ID:ekaputra07,项目名称:bokerface,代码行数:97,代码来源:site.py


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