Closed fake-name closed 8 years ago
Ultra-terse fix:
I replaced the init_app()
call in flask_plugins/__init__.py
with the following:
def init_app(self, app, plugin_folder, plugin_import_path):
self._event_manager = EventManager(app)
app.plugin_manager = self
app.jinja_env.globals["emit_event"] = self._event_manager.template_emit
self.app = app
self.plugin_folder = plugin_folder
self.base_plugin_package = plugin_import_path
self.setup_plugins()
and it works the way I want with no other changes.
Could you create a pull request with some tests for this? Thanks! :)
@sh4nks - Sure, but the issue is it'll result in breaking changes (e.g. the old behaviour no longer works). As such, I wasn't sure if it was even something you'd be interested in.
I figured I'd ask first.
Basically, I'm trying to tack FlaskBB onto an existing flask app, having them share the overall flask instance.
As such, I have a folder structure like the following:
I can force flask_plugins to properly recognize where the plugin dir is by passing in the plugin path as an absolute path to
plugin_manager.init_app(app, plugin_folder={itempath})
, but it appears that it then tries to use the literal path as part of an import path (e.g. it fails withImportError: No module named 'flaskbb./media/Storage/Scripts/wlnupdates/flaskbb'
).A better solution (IMHO), would be to replace the two parameters currently used (
base_app_folder
,plugin_folder
) which are concatenated to form the import path with two values, one being the filesystem path to the relevant directory, and the second being the import path to the same directory.That would allow things to be arranged however the end-user wants on-disk, and as long as the files in the filesystem path can be imported by the import path, it would work.