Exemple #1
0
def clearCache(request):
    cache.clear()
    import os
    avator_path=STATIC_ROOT+"/avator/"
    paths = os.listdir(avator_path)
    for path in paths:
        filePath = os.path.join( avator_path, path)
        if os.path.isfile(filePath):
            os.remove(filePath)
    return HttpResponseRedirect("/admin/tools")
Exemple #2
0
def edit(post_id):
    post = Post.query.get_or_404(post_id)
    form = PostForm(request.form, post)
    form.categories.choices = [(c.id, c.title) for c in Category.query.all()]
    if not form.categories.data:
        form.categories.data = [c.id for c in post.categories]

    if form.validate_on_submit():
        post.title = form.title.data
        post.slug = form.slug.data.lower()
        post.status = form.status.data
        post.body = form.body.data
        post.pub_date = form.pub_date.data
        post.categories = Category.query.filter(Category.id.in_(form.categories.data)).all()
        db.session.commit()
        if post.status == Post.DRAFT:
            return redirect(url_for('admin.edit', post_id=post.id))
        cache.clear()
        return redirect(url_for('public.post', slug=post.slug))

    return render_template('admin/edit.html', post=post, form=form)
Exemple #3
0
''' Runs our blog engine. Register blueprints, configurations and initialize
exetensions here. Clears cache before launching app.'''
from flask.ext.uploads import configure_uploads, patch_request_class
from blog import app, login_manager, md, admin, db, photos, cache
from blog.posts.models import Post
from blog.admin.posts import posts

app.config.from_object('config')
app.register_blueprint(posts)

# initialize extensions
configure_uploads(app, photos)
patch_request_class(app, 32 * 1024 * 1024)
login_manager.init_app(app)
md.init_app(app)
db.init_app(app)
cache.init_app(app, config=app.config)

with app.app_context():
	cache.clear()

if __name__ == '__main__':
	app.run(debug=True)
Exemple #4
0
def clear_cache():
    cache.clear()
    return 'OK'
Exemple #5
0
''' Runs our blog engine. Register blueprints, configurations and initialize
exetensions here. Clears cache before launching app.'''
from flask.ext.uploads import configure_uploads, patch_request_class
from blog import app, login_manager, md, admin, db, photos, cache
from blog.posts.models import Post
from blog.admin.posts import posts

app.config.from_object('config')
app.register_blueprint(posts)

# initialize extensions
configure_uploads(app, photos)
patch_request_class(app, 32 * 1024 * 1024)
login_manager.init_app(app)
md.init_app(app)
db.init_app(app)
cache.init_app(app, config=app.config)

with app.app_context():
    cache.clear()

if __name__ == '__main__':
    app.run(debug=True)