Commits

danjac  committed fc16f30

uploads configuration

  • Participants
  • Parent commits 62dc9f7
  • Branches photos

Comments (0)

Files changed (2)

File newsmeme/__init__.py

 from flaskext.babel import Babel, gettext as _
 from flaskext.themes import setup_themes
 from flaskext.principal import Principal, RoleNeed, UserNeed, identity_loaded
+from flaskext.uploads import configure_uploads, patch_request_class
 
 from newsmeme import views
 from newsmeme import helpers
 from newsmeme.models import User, Tag
 from newsmeme.helpers import render_template
-from newsmeme.extensions import db, mail, oid, cache
+from newsmeme.extensions import db, mail, oid, cache, uploads
 
 DEBUG = True
 
 CACHE_TYPE = "simple"
 CACHE_DEFAULT_TIMEOUT = 300
 
+UPLOADED_FILES_DEST = 'uploads'
+UPLOADS_DEFAULT_DEST = 'uploads'
+
 def configure_logging(app):
     if app.debug:
         return
     cache.init_app(app)
 
     babel = Babel(app)
+
     setup_themes(app)
+
+    configure_uploads(app, (uploads,))
+    patch_request_class(app)
+
     principal = Principal(app)
 
     # identity loading

File newsmeme/extensions.py

 from flaskext.openid import OpenID
 from flaskext.sqlalchemy import SQLAlchemy
 from flaskext.cache import Cache
-from flaskext.uploads import UploadSet
+from flaskext.uploads import UploadSet, IMAGES
 
 __all__ = ['oid', 'mail', 'db', 'cache', 'uploads']
 
 mail = Mail()
 db = SQLAlchemy()
 cache = Cache()
-uploads = UploadSet()
 
+uploads = UploadSet('photos', extensions=IMAGES)
+