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


Python Photo.name方法代码示例

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


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

示例1: savePhoto

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import name [as 别名]
 def savePhoto(self, galleryId, photoId, photoName, photoDescription, photoPosition, file):
     photo = None
     if(photoId):
         photo = Photo.objects.get(id=photoId)
     else:
         gid = uuid.uuid1().__str__()
         gid = gid.replace('-', '')
         photo = Photo()
         photo.id = gid
     photo.name = photoName
     photo.description = photoDescription
     photo.position = photoPosition
     photo.gallery_id = galleryId
     
     if(file):
         photoType = file.name.split('.')
         photo.type = photoType[1] if photoType.__len__() == 2 else ''
         
         destination  = open(constant.upload_path + galleryId + '/' +
                             photo.id + '.' + photo.type, 'wb')
         try:
             for chunk in file.chunks():
                 destination.write(chunk)
         finally:
             destination.close()
             
     photo.save()   
开发者ID:rsdgjb,项目名称:PortableApp,代码行数:29,代码来源:galleryService.py

示例2: add_photo

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import name [as 别名]
def add_photo(user_state, object_id, name, from_name, link, source):
    photo_list = Photo.objects.filter(object_id=object_id)
    photo = None
    if len(photo_list) == 0:
        photo = Photo()
        photo.user_state = user_state
        photo.object_id = object_id
        photo.retrieval_time = int(time.time())
        photo.name = name
        photo.from_name = from_name
        photo.link = link
        photo.source = source
        photo.save()
    else:
        photo = photo_list[0]
    return photo
开发者ID:RobFisher,项目名称:fbtools,代码行数:18,代码来源:ajax.py

示例3: upload_pic

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import name [as 别名]
def upload_pic(request):
    if request.method == 'POST':
        form = ImageUploadForm(request.POST, request.FILES)
        if form.is_valid():
            user = request.user
            photo = Photo()
            photo.photo = form.cleaned_data['image']
            photo.public = form.cleaned_data['public']
            photo.name = form.cleaned_data['name']
            photo.owner = user.customuser
            photo.save()
            # print(photo.photo)
            return HttpResponseRedirect('/photos/success_upload/')
    elif request.method == 'GET':
        form = ImageUploadForm()
        return render(request, 'photos/upload.html', {'form': form})
    return render(request, 'photos/upload.html', {'form': form})
开发者ID:darxsys,项目名称:PUS,代码行数:19,代码来源:views.py

示例4: upload

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import name [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

示例5: post

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import name [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


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