From 0e8f21086641a18c0a807aeb48d032ef1c8b012b Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Mon, 6 Nov 2017 18:51:57 +0100 Subject: [PATCH] channelstream: use proper pyramid event to create storage on app creation. --- rhodecode/apps/channelstream/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rhodecode/apps/channelstream/__init__.py b/rhodecode/apps/channelstream/__init__.py index eebee2d0..69497120 100644 --- a/rhodecode/apps/channelstream/__init__.py +++ b/rhodecode/apps/channelstream/__init__.py @@ -20,6 +20,7 @@ import os +from pyramid.events import ApplicationCreated from pyramid.settings import asbool from rhodecode.config.routing import ADMIN_PREFIX @@ -57,6 +58,14 @@ PLUGIN_DEFINITION = { } +def maybe_create_history_store(event): + # create plugin history location + settings = event.app.registry.settings + history_dir = settings.get('channelstream.history.location', '') + if history_dir and not os.path.exists(history_dir): + os.makedirs(history_dir, 0750) + + def includeme(config): settings = config.registry.settings PLUGIN_DEFINITION['config']['enabled'] = asbool( @@ -71,10 +80,7 @@ def includeme(config): PLUGIN_DEFINITION['name'], PLUGIN_DEFINITION['config'] ) - # create plugin history location - history_dir = PLUGIN_DEFINITION['config']['history.location'] - if history_dir and not os.path.exists(history_dir): - os.makedirs(history_dir, 0750) + config.add_subscriber(maybe_create_history_store, ApplicationCreated) config.add_route( name='channelstream_connect',