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


Python Image.title方法代码示例

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


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

示例1: receive

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
def receive():
    data = request.data
    data = xmltodict.parse(data)['xml']
    if data['MsgType'] == 'text':
        return send_text(data['FromUserName'], 'hi')
    if data['MsgType'] == 'image':
        token = current_access_token()
        file_url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s' % (token, data['MediaId'])
        file = requests.get(file_url, stream=True).raw
        i = Image()
        i.image = file
        uuid = shortuuid.ShortUUID().random(length=6)
        while Image.objects(iid=uuid):
            uuid = shortuuid.ShortUUID().random(length=6)
        i.iid = uuid
        i.title = data['MediaId']
        i.user = system_user
        i.description = ''
        i.tags = []
        i.save()
        return send_text(
            data['FromUserName'], '업로드 성공, 사진주소:%s%s' % (
                request.url_root[:-1], url_for('light-cms.image', iid=i.iid)
            )
        )
开发者ID:initNirvana,项目名称:Easyphotos,代码行数:27,代码来源:wc.py

示例2: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
    def post(self):
      "Upload via a multitype POST message"
      if self.request.get('img'):
        try:
          # check we have numerical width and height values
          width = int(self.request.get("width"))
          height = int(self.request.get("height"))
        except ValueError:
          # if we don't have valid width and height values
          # then just use the original image
          image_content = google.appengine.api.images.resize(self.request.get("img"), 
          IMAGE_WIDTH, IMAGE_HEIGHT)
          thumb_content = google.appengine.api.images.resize(self.request.get("img"), 100, 100)
        else:
            # if we have valid width and height values
            # then resize according to those values
            image_content = google.appengine.api.images.resize(self.request.get("img"), width, height)
            # always generate a thumbnail for use on the admin page
            thumb_content = google.appengine.api.images.resize(self.request.get("img"), 100, 100)
      else:
        image_content = None
        if not self.request.get('key'):
          logging.critical('No key and no image! Cannot save image.')
          return self.redirect('/admin')

      # check if image is being edited
      if self.request.get('key'):
        image = db.get(self.request.get("key"))
        if self.request.get('position'):
          import datetime
          position = int(self.request.get('position'))
          images = imageQuery().fetch(100)
          offset_image = images.pop(position- 1)
          if position == 1: 
            time_offset = -datetime.timedelta(milliseconds=10)
          else:
            time_offset = datetime.timedelta(milliseconds=10)
          if not offset_image.key() == image.key(): 
            image.date = offset_image.date + time_offset
                
      else:
      # create the image object
        image = Image()
        image.user = users.get_current_user()
      image.title = self.request.get('title')
      if image_content:
      # and set the properties to the relevant values
        image.image = db.Blob(image_content)
        # we always store the original here in case of errors
        # although it's currently not exposed via the frontend
        image.thumb = db.Blob(thumb_content) 
              
      # store the image in the datasore
      image.put()
      # and redirect back to the admin page
      self.redirect('/admin')
开发者ID:jamslevy,项目名称:portfolio,代码行数:58,代码来源:admin.py

示例3: test_create

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
    def test_create(self):
        """
        Simple test (without image file) to see if image can be created
        """

        i = Image()
        i.title = "Test"
        i.description = "Long image image description"
        i.description_short = "Short image description"
        i.save()

        db_i = Image.objects.get(pk=1)

        self.assertEqual(i.title, db_i.title)
        self.assertEqual(i.description, db_i.description)
        self.assertEqual(i.description_short, db_i.description_short)
开发者ID:hayk912,项目名称:bidpart,代码行数:18,代码来源:tests.py

示例4: multiuploader

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
def multiuploader(request):
    if request.method == 'POST':
        log.info('received POST to main multiuploader view')
        if request.FILES == None:
            return HttpResponseBadRequest('Must have files attached!')

        #getting file data for farther manipulations
        file = request.FILES[u'files[]']
        wrapped_file = UploadedFile(file)
        filename = wrapped_file.name
        file_size = wrapped_file.file.size
        log.info ('Got file: "'+str(filename)+'"')

        #writing file manually into model
        #because we don't need form of any type.
        image = Image()
        image.title=str(filename)
        image.image=file
        image.save()
        log.info('File saving done')

        #getting url for photo deletion
        file_delete_url = '/delete/'
        
        #getting file url here
        file_url = '/'

        #getting thumbnail url using sorl-thumbnail
        im = get_thumbnail(image, "80x80", quality=50)
        thumb_url = im.url

        #generating json response array
        result = []
        result.append({"name":filename, 
                       "size":file_size, 
                       "url":file_url, 
                       "thumbnail_url":thumb_url,
                       "delete_url":file_delete_url+str(image.pk)+'/', 
                       "delete_type":"POST",})
        response_data = simplejson.dumps(result)
        return HttpResponse(response_data, mimetype='application/json')
    else: #GET
        return render_to_response('multiuploader_main.html', 
                                  {'static_url':settings.MEDIA_URL,
                                   'open_tv':u'{{',
                                   'close_tv':u'}}'}, 
                                  )
开发者ID:Alren-huang,项目名称:django_multiuploader_demo,代码行数:49,代码来源:views.py

示例5: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
 def post(self):
     url = self.request.get("img_url")
     if url:
         inputimage = urlfetch.fetch(url)
         if inputimage.status_code == 200:
             image = Image()
             image.source_url = url
             image.full_size = inputimage.content
             image.title = "Test image"
             # TODO move to task queue
             image.thumb_nail = images.resize(image.full_size, 64, 64)
             image.put()
             puzzle = Puzzle()
             puzzle.name = "Test puzzle"
             puzzle.image = image
             puzzle.put()
             self.redirect("/svg")
开发者ID:cw,项目名称:HTML5-Hacks,代码行数:19,代码来源:main.py

示例6: drop

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
def drop():
    file = request.files['file']
    i = Image()
    i.title = file.filename
    i.image = file
    uuid = shortuuid.ShortUUID().random(length=6)
    while Image.objects(iid=uuid):
        uuid = shortuuid.ShortUUID().random(length=6)
    i.iid = uuid
    if login.current_user.is_active():
        i.user = login.current_user._get_current_object()
    else:
        i.user = system_user
    i.description = ''
    i.tags = []
    i.save()
    return jsonify(id=uuid)
开发者ID:initNirvana,项目名称:Easyphotos,代码行数:19,代码来源:views.py

示例7: gallery_drop

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
def gallery_drop(gid):
    if not login.current_user.is_active():
        flash('앨범기능엔 로그인이 필요합니다')
        return redirect(url_for('light-cms.user_login'))
    g = Gallery.objects.get_or_404(gid=gid)
    file = request.files['file']
    i = Image()
    i.gallery.append(g)
    i.title = file.filename
    i.image = file
    uuid = shortuuid.ShortUUID().random(length=6)
    while Image.objects(iid=uuid):
        uuid = shortuuid.ShortUUID().random(length=6)
    i.iid = uuid
    i.user = login.current_user._get_current_object()
    i.description = ''
    i.tags = []
    i.save()
    return jsonify(id=uuid)
开发者ID:initNirvana,项目名称:Easyphotos,代码行数:21,代码来源:views.py

示例8: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
    def post(self, key):
        post = self.request.POST
        edit = self.request.get('kind')
        form_data = dict((k, post.get(k, ''))
                          for k in ('title', 'author', 'date', 'body', 'picture','video'))
        template_dict = {'form_data': form_data, 'key': key, 'show_form' : True,'members': Member.all(),
                         'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name")}

        try:
                this_date = utils.parse_date(form_data['date'])
        except ValueError:
                template_dict['message'] = \
                    'Date is not in the correct format (YYYY-MM-DD).'
        else:
                if key == 'new':
                    try:
                        if(edit=="news"):
                             thing = NewsArticleNew(
                                  title=post['title'],
                                  author=Member.get_by_id(int(post['author'])),
                                  date=this_date,
                                  body=post['body']
                             )
                        elif(edit=="talk"):
                             thing = TalkNew(
                                  title=post['title'],
                                  author=Member.get_by_id(int(post['author'])),
                                  date=this_date,
                                  body=post['body']
                             )
                             if('video' in post):
                                 talk.video = post['video']
                        elif(edit=="hack"):
                             thing = Hack(
                                  title=post['title'],
                                  date=this_date,
                                  body=post['body']
                             )
                        if(edit=="news" or edit=="hack"):
                             if(self.request.get("picture")):
                                  pictureImage = Image(
                                               picture=images.resize(self.request.get("picture"), self.image_height, self.image_width),
                                               name="no-name",title=" ",alt=" ")
                                  if post['picture_title'] :
                                     pictureImage.title=post['picture_title']
                                  if post['picture_alt'] :
                                     pictureImage.alt=post['picture_alt']
                                  pictureImage.put()
                                  thing.picture=pictureImage
                             elif(post['picture_alias']!="none"):
                                  thing.picture=Image.get_by_id(int(post['picture_alias']))

                        thing.put()
                        template_dict['key']=thing.key

                    except datastore_errors.Error:
                        template_dict['message'] = \
                            'Could not create new %s.' % self.thing_descriptors.get(edit)
                    else:
                        template_dict['message'] = '%s created.' % self.thing_descriptors.get(edit)
                        template_dict['show_form'] = False
                else:
                    try:
                        if(edit=="news"):
                             thing = NewsArticleNew.get(Key(key))
                             thing.title = form_data['title']
                             thing.author = Member.get_by_id(int(post['author']))
                             thing.date = this_date
                             thing.body = form_data['body']

                        elif(edit=="talk"):

                             thing = TalkNew.get(Key(key))
                             thing.title = form_data['title']
                             thing.date = this_date
                             thing.body = form_data['body']

                        elif(edit=="hack"):

                             thing = Hack.get(Key(key))
                             thing.title = form_data['title']
                             thing.date = this_date
                             thing.body = form_data['body']

                        if(self.request.get("picture")):
                             pictureImage = Image(picture=images.resize(self.request.get("picture"), self.image_height, self.image_width),
                                                   name="no-name",title=" ",alt=" ")
                             if post['picture_title'] :
                                 pictureImage.title=post['picture_title']
                             if post['picture_alt'] :
                                 pictureImage.alt=post['picture_alt']
                             pictureImage.put()
                             thing.picture = pictureImage
                        elif(post['picture_alias']!="none"):
                                  thing.picture=Image.get_by_id(int(post['picture_alias']))

                        if 'delete_picture' in post:
                             thing.picture=None

                    except BadKeyError:
#.........这里部分代码省略.........
开发者ID:Man-UP,项目名称:website,代码行数:103,代码来源:handlers.py

示例9: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import title [as 别名]
    def post(self):
		# Grab album from url
		urlstring = self.request.POST['album']
		album_key = ndb.Key(urlsafe=urlstring)
		album = album_key.get()
		# Check whether we're storing a album or a Question
		if self.request.GET['album'] == '1':
			album.title = self.request.POST['albumTitle']
			album.category = self.request.POST['categoryTitle']
			album.put()
			time.sleep(0.1)
			# Save album and redirect to edit if the user clicks on 'Save and continue editing'
			# Else, save album and go back to the main page which lists all albums
			if self.request.POST.get('stay') == '1':
				self.redirect('/edit?album=1&id='+urlstring)
			else:
				if album.album_type == 'match':
					self.redirect('/match')
				elif album.album_type == 'correlate':
					self.redirect('/correlate')
				else:
					self.redirect('/oddmanout')
		else:
			# Create Question with the album as parent for strong consistency
			question = ""
			new = "1"
			if self.request.POST['question'] == "":
				question = Question(parent=album_key)
				question.question_id = question.put().id()
			else:
				new = "0"
				question_url = self.request.POST['question']
				question_key = ndb.Key(urlsafe=question_url)
				question = question_key.get()
			question.title = self.request.get('title')
			question.fact = self.request.get('fact')
			question.effect = self.request.get('revealEffect')
			question.difficulty = self.request.get('difficulty')
			# Create answer choices
			answer = int(self.request.get('correct_answer'))
			input_images = self.request.get('image', allow_multiple=True)
			num_images = 4
			if album.album_type == 'correlate':
				num_images = 5
			image_list = []
			for i in range(num_images):
				img = ""
				input_img = input_images[i]
				# If old retrieve the Image
				if new == "0":
					img = question.images[i]
				else:
					img = Image()
				# Resize image
				if input_img:
					op_img = images.Image(input_img)
					op_img.resize(width=256, height=256, crop_to_fit=True)
					result_img = op_img.execute_transforms(output_encoding=images.JPEG)
					img.image = result_img
				# Set the title and correct fields
				if answer == i:
					img.title = "correct_answer_"+str(i)
					img.correct = True
				elif num_images == 5 and i == 0: # This is if the album is of type Correlate
					img.title = "main_image_"+str(i)
					img.correct = False
				else:
					img.title = "incorrect_answer_"+str(i)
					img.correct = False
			 	# If old Question, free up the old Image and put in new Image 
				if new == "0":
					question.images.pop(i)
					question.images.insert(i, img)
				else:
					question.images.append(img)

			question.put()
			# Query all Question(s) for the album in recently added order for /create
			# Retrieve previously input values, and indicate whether this is a new album (edit)
			questions = Question.query(ancestor=album_key).order(-Question.date).fetch()
			retrieve = 1
			edit = self.request.GET['edit']
			template_values = {
				'album': album,
				'album_type': album.album_type,
				'questions': questions,
				'edit': edit,
				'retrieve': retrieve
			}
			template = JINJA_ENVIRONMENT.get_template('create.html')
			self.response.write(template.render(template_values))
开发者ID:nischalshrestha,项目名称:recognize,代码行数:93,代码来源:recognize.py


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