rduplain/flask-script — Issue #3: Better support for derived commands
Author: rduplain
Created: 2012-02-29 15:45:16+00:00
State: open
Labels: bug, import

I'm trying to subclass flaskext.script.Server and have run into several problems. The splitting of option specifications between __init__, get_options and run doesn't seem to make much sense. I can't easily override individual options from the superclass (e.g., making host default to 0.0.0.0 instead of 127.0.0.1). This is the best I could figure out:

#!python

class Record(Server):

description = 'records responses from the Xxxx data service'

def __init__(self, host='0.0.0.0', **kw):
super(Record, self).__init__(host, **kw)

def get_options(self):
return (super(Record, self).get_options() +
(Option('-o', '--xxxx-host',
dest='xxxx_host', required=True),))

def run(self, app, xxxx_host, *args, **kw):
app.config.update(XXXX_HOST=xxxx_host, PLAYBACK=False)
super(Record, self).run(app, *args, **kw)

but it isn't exactly pretty.

---------------------------------------
- Bitbucket: https://bitbucket.org/danjac/flask-script/issue/3
- Originally Reported By: [Nicholas Riley](http://bitbucket.org/njr)
- Originally Created At: 2010-07-13 19:28:32