# HG changeset patch # User Marcin Kuzminski # Date 2017-11-06 17:51:57 # Node ID 7829bcfeb1f570ee8b3014c1c88e7d952256618f # Parent 7808aec61cb3b520ce0b6bdd9214e8412f165ffd channelstream: use proper pyramid event to create storage on app creation. diff --git a/rhodecode/apps/channelstream/__init__.py b/rhodecode/apps/channelstream/__init__.py --- 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',