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


Python UploadSet._config方法代码示例

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


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

示例1: test_save_namedext

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_save_namedext(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='boat.jpg')
     res = uset.save(tfs, name='photo_123.')
     assert res == 'photo_123.jpg'
     assert tfs.saved == '/uploads/photo_123.jpg'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例2: test_conflict

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_conflict(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     self.extant('/uploads/foo.txt')
     res = uset.save(tfs)
     assert res == 'foo_1.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例3: test_implicit_folder

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_implicit_folder(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='boat.jpg')
     res = uset.save(tfs, name='someguy/photo_123.')
     assert res == 'someguy/photo_123.jpg'
     assert tfs.saved == '/uploads/someguy/photo_123.jpg'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例4: test_save_folders

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_save_folders(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     res = uset.save(tfs, folder='someguy')
     assert res == 'someguy/foo.txt'
     assert tfs.saved == '/uploads/someguy/foo.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例5: test_save_named

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_save_named(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     res = uset.save(tfs, name='file_123.txt')
     assert res == 'file_123.txt'
     assert tfs.saved == '/uploads/file_123.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:9,代码来源:test-uploads.py

示例6: _configuploadset

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
def _configuploadset(name, constraint):
    uset = UploadSet(name, constraint)
    uset._config = UploadConfiguration(
        conf.UPLOADS_DEFAULT_DEST,
        conf.UPLOADED_FILES_URL,
    )
    return uset
开发者ID:gabinetedigital,项目名称:gd,代码行数:9,代码来源:model.py

示例7: test_multi_conflict

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_multi_conflict(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo.txt')
     self.extant('/uploads/foo.txt',
                 *('/uploads/foo_%d.txt' % n for n in range(1, 6)))
     res = uset.save(tfs)
     assert res == 'foo_6.txt'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:10,代码来源:test-uploads.py

示例8: test_conflict_without_extension

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_conflict_without_extension(self):
     # Test case for issue #7.
     uset = UploadSet('files', extensions=(''))
     uset._config = Config('/uploads')
     tfs = TestingFileStorage(filename='foo')
     self.extant('/uploads/foo')
     res = uset.save(tfs)
     assert res == 'foo_1'
开发者ID:bcb,项目名称:flask-uploads,代码行数:10,代码来源:test-uploads.py

示例9: test_path

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_path(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     assert uset.path('foo.txt') == '/uploads/foo.txt'
     assert uset.path('someguy/foo.txt') == '/uploads/someguy/foo.txt'
     assert (uset.path('foo.txt', folder='someguy') ==
             '/uploads/someguy/foo.txt')
     assert (uset.path('foo/bar.txt', folder='someguy') ==
             '/uploads/someguy/foo/bar.txt')
开发者ID:bcb,项目名称:flask-uploads,代码行数:11,代码来源:test-uploads.py

示例10: test_secured_filename

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_secured_filename(self):
     uset = UploadSet('files', ALL)
     uset._config = Config('/uploads')
     tfs1 = TestingFileStorage(filename='/etc/passwd')
     tfs2 = TestingFileStorage(filename='../../myapp.wsgi')
     res1 = uset.save(tfs1)
     assert res1 == 'etc_passwd'
     assert tfs1.saved == '/uploads/etc_passwd'
     res2 = uset.save(tfs2)
     assert res2 == 'myapp.wsgi'
     assert tfs2.saved == '/uploads/myapp.wsgi'
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:13,代码来源:test-uploads.py

示例11: test_filenames

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_filenames(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     namepairs = (
         ('foo.txt', True),
         ('boat.jpg', True),
         ('warez.exe', False)
     )
     for name, result in namepairs:
         tfs = TestingFileStorage(filename=name)
         assert uset.file_allowed(tfs, name) is result
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:13,代码来源:test-uploads.py

示例12: test_default_extensions

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
 def test_default_extensions(self):
     uset = UploadSet('files')
     uset._config = Config('/uploads')
     extpairs = (('txt', True), ('jpg', True), ('exe', False))
     for ext, result in extpairs:
         assert uset.extension_allowed(ext) is result
开发者ID:franciscogodoy,项目名称:flask-appengine-template,代码行数:8,代码来源:test-uploads.py

示例13: import

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
                   render_template, redirect, url_for, send_from_directory,
                   flash, abort)
from flask.ext.pymongo import PyMongo
from flaskext.uploads import (UploadSet, configure_uploads, IMAGES,
                              DATA, DOCUMENTS, UploadConfiguration)
from logging import FileHandler
from werkzeug import secure_filename
from utilities import ObjectIdCleaner


app = Flask(__name__)
app.config.from_pyfile('conf.py')
mongo = PyMongo(app)
plugin_upload = UploadSet('plugins', ('js', 'css'),
                          default_dest=lambda app: app.instance_path)
plugin_upload._config = UploadConfiguration(app.config.get(
    'PLUGIN_UPLOAD_FOLDER'))


files_upload = UploadSet('files', IMAGES + DOCUMENTS + DATA + ('pdf',),
                         default_dest=lambda app: app.instance_path)
files_upload._config = UploadConfiguration(app.config.get(
    'FILE_UPLOAD_FOLDER'))

configure_uploads(app, plugin_upload)
configure_uploads(app, files_upload)
app.register_module(cache.cache, url_prefix='/cache')


bson.ObjId = bson.objectid.ObjectId  # handy reference to otherwise long name

开发者ID:janastu,项目名称:climate-south-asia,代码行数:32,代码来源:server.py

示例14: create_app

# 需要导入模块: from flaskext.uploads import UploadSet [as 别名]
# 或者: from flaskext.uploads.UploadSet import _config [as 别名]
import subprocess
import json
import os
import zipfile
from functools import wraps


app = create_app()

UPLOAD_DEST = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                           'static/data')

uploaded_files = UploadSet('tracks', ARCHIVES,
                           default_dest=lambda app: app.instance_path)
configure_uploads(app, uploaded_files)
uploaded_files._config = UploadConfiguration(UPLOAD_DEST)

configure_uploads(app, uploaded_files)
mongo = PyMongo(app)


def check_auth(username, password):
    """This function is called to check if a username /
    password combination is valid.
    """
    users = app.config.get('USERS')
    passkey = app.config.get('SECRET')[0]
    if username in users and passkey == password:
        return username

开发者ID:janastu,项目名称:followsheep-tracker-server,代码行数:31,代码来源:emule.py


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