示例#1
0
    def do_upload_file(self, fp, base_file, date, visibility):
        yield '<dt>Uploading <span class="filename">%s</span>&hellip;&nbsp;' % base_file

        if is_zip_fp(fp):
            yield '</dt>\n<dd>\n'
            for y in self.do_upload_zip(fp, visibility):
                yield y
            yield '</dd>\n'
        else:
            try:
                user = self.db.user
                id = insert.import_image(datafp=fp,
                                         orig_filename=base_file,
                                         owner=user,
                                         photographer=user,
                                         public=visibility,
                                         collection=self.parent.collection.db,
                                         upload=self.db,
                                         keywords=[],
                                         record_time=date)
                img = image.Image(self.parent.collection, id)
                r = H('OK, Picture #%s</dt><dd><ul class="thumb-set"><li>%s</ul></dd>\n') % \
                    (id, img.ui.thumbnail())
            except insert.AlreadyPresentException, msg:
                r = H('</dt><dd>Already present (#%s)</dd>\n') % msg
            except insert.ImportException, msg:
                r = H('</dt><dd class="error">failed: %s</dd>\n') % msg
示例#2
0
        def do_upload_file(self, fp, base_file, date,
                           user, camera, keywords, visibility, upload):
            yield '<dt>Uploading <span class="filename">%s</span>&hellip;&nbsp;' % base_file

            if is_zip_fp(fp):
                yield '</dt>\n<dd>\n'
                for y in self.do_upload_zip(fp, user, camera, keywords, visibility, upload):
                    yield y
                yield '</dd>\n'
            else:
                try:
                    id = insert.import_image(datafp=fp,
                                             orig_filename=base_file,
                                             owner=user,
                                             photographer=user,
                                             public=visibility,
                                             collection=self.collection.db,
                                             keywords=keywords,
                                             camera=camera,
                                             upload=upload,
                                             record_time=date)
                    imageui = image.ImageDir(self.collection)
                    r = H('OK, Picture #%s</dt><dd>%s</dd>\n') % \
                        (id, imageui.thumb_img(db.Picture.get(id), False))
                except insert.AlreadyPresentException, msg:
                    r = H('</dt><dd>Already present (#%s)</dd>\n') % msg
                except insert.ImportException, msg:
                    r = H('</dt><dd class="error">failed: %s</dd>\n') % msg
示例#3
0
    def do_upload(self, img, user, added, skipped):
        request = quixote.get_request()

        if not isinstance(img, quixote.http_request.Upload):
            return
        
        visibility=request.form.get('visibility', 'public')
        keywords=request.form.get('keywords', [])
        if not isinstance(keywords, list):
            keywords = [ keywords ]

        try:
            id=insert.import_image(img.fp,
                                   orig_filename=img.orig_filename,
                                   owner=user,
                                   photographer=user,
                                   public=visibility,
                                   collection=self.db,
                                   keywords=keywords)
            added.append(id)
        except insert.AlreadyPresentException, x:
            skipped[img.orig_filename] = x.id