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


Python Photo.gql方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import gql [as 别名]
    def get(self):
        user = users.get_current_user()
        albumName = self.request.get('name')
        nickname = users.get_current_user().nickname()
        
        # Clear all photo data stored in the db
        query = "Where owner = '%s'" % (user)
        allPhoto = Photo.gql(query)
        db.delete(allPhoto)
        # Get selected album with owner
        query = "Where albumName = '%s' AND owner ='%s'" % (albumName, nickname)
        selectedAlbum = Album.gql(query)
        # Pre-select if album is empty
        if selectedAlbum[0].albumPhoto == '0':
            template_values = {
                'user': user,
                'albumName': albumName,
            }
            render_template(self, 'photo.html', template_values)

        gd_client = gdata.photos.service.PhotosService()
        photoList = gd_client.GetFeed('/data/feed/api/user/%s/albumid/%s?kind=photo' % (user, selectedAlbum[0].albumID))

        # initialize Lock and Queue objects
        lock = Lock()
        photoQueue = Queue()

        for photo in photoList.entry:
            photoQueue.put(photo)

        # start consumer
        for i in range(numConsumer):
            worker = Thread(target=consumer, args=(photoQueue, selectedAlbum[0].albumPhoto, nickname, lock))
            worker.start()

#        for thread in joinable:
#            thread.join()
        photoQueue.join()

        # All consumer thread are finished, empty photoQueue
#        with stdout_mutex:
        print "All done"

        lock.acquire()
        time.sleep(1)
        query = "Where owner = '%s'" % (nickname)
        allPhoto = Photo.gql(query)
        print allPhoto.count()

        template_values = {
                'user': user,
                'allPhoto': allPhoto,
                'albumName': albumName,
        }
        lock.release()

        render_template(self, 'photo.html', template_values)
开发者ID:JimmyCDChen,项目名称:photoAlbum,代码行数:59,代码来源:main.py

示例2: post

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

        spam = self.request.get('spam')
        if spam.upper() != "NO":
            return
        name = self.request.get('name')
        email = self.request.get('email')
        url = self.request.get('url')
        notify = self.request.get('notify').upper() == "ON"
        text = self.request.get('text')
        if not text:
            return

        comment = Comment(photo=photo,
                          name=name,
                          email=email,
                          url=url,
                          notify=notify,
                          text=text)
        comment.put()
开发者ID:ibz,项目名称:nuages,代码行数:23,代码来源:photo.py

示例3: post

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

示例4: get

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import gql [as 别名]
 def get(self, id):
     photo = Photo.gql("WHERE id = :1", id).get()
     comments = sorted(photo.comment_set)
     self.render_html("photo_comments", {'photo': photo,
                                         'comments': comments})
开发者ID:ibz,项目名称:nuages,代码行数:7,代码来源:photo.py

示例5: get

# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import gql [as 别名]
 def get(self, id=None):
     if id:
         photo = Photo.gql("WHERE id = :1", id).get()
     else:
         photo = None
     self.render_html("photo_edit", {'photo': photo})
开发者ID:ibz,项目名称:nuages,代码行数:8,代码来源:admin.py


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