flask-script icon indicating copy to clipboard operation
flask-script copied to clipboard

Submanager uses wrong app instance

Open lolsborn opened this issue 9 years ago • 0 comments

Provided example

def gen_admin(app, **kwargs):
    from myweb.admin import MyAdminApp
    ## easiest but possibly incomplete way to copy your settings
    return MyAdminApp(config=app.config, **kwargs)
sub_manager = Manager(gen_admin)

manager = Manager(MyApp)
manager.add_command("admin", sub_manager)

Issues:

  1. doc shows default commands being used, but the Manager isn't being passed with_default_commands=True, but it doesn't seem to matter as with_default_commands doesn't seem to work anyhow. However, If you call manager.add_default_commands() manually the commands are added to the sub-manager.
  2. Submanagers that are Flask app instances don't end up using the app instance that is provided to the Manager, but the root managers app instance.

Steps to repeat

This is a really basic example, there are a number of ways to set this up, but they all end up with runserver or showUrls returning routes for the app attached to the root manager.

admin_manager = Manager(app=admin_app, usage="Perform commands on admin server")
admin_manager.add_command("runserver", Server())
admin_manager.add_command("spec", ShowUrls())
manager.add_command("admin", admin_manager)

lolsborn avatar Apr 22 '16 20:04 lolsborn