<p dir="auto">I'd like to be able to register "sub-blueprints" using <code class="notranslate">Blueprint.register_blueprint(*args, **kwargs)</code>. This would register the nested blueprints with an app when the "parent" is registered with it. All parameters are preserved, other than <code class="notranslate">url_prefix</code>, which is handled similarly to in <code class="notranslate">add_url_rule</code>. A naíve implementation could look like this:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Blueprint(object):
    ...

    def register_blueprint(self, blueprint, **options):
        def deferred(state):
            url_prefix = options.get('url_prefix')
            if url_prefix is None:
                url_prefix = blueprint.url_prefix
            if 'url_prefix' in options:
                del options['url_prefix']

            state.app.register_blueprint(blueprint, url_prefix, **options)
        self.record(deferred)"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">Blueprint</span>(<span class="pl-s1">object</span>):
    ...

    <span class="pl-k">def</span> <span class="pl-en">register_blueprint</span>(<span class="pl-s1">self</span>, <span class="pl-s1">blueprint</span>, <span class="pl-c1">**</span><span class="pl-s1">options</span>):
        <span class="pl-k">def</span> <span class="pl-en">deferred</span>(<span class="pl-s1">state</span>):
            <span class="pl-s1">url_prefix</span> <span class="pl-c1">=</span> <span class="pl-s1">options</span>.<span class="pl-en">get</span>(<span class="pl-s">'url_prefix'</span>)
            <span class="pl-k">if</span> <span class="pl-s1">url_prefix</span> <span class="pl-c1">is</span> <span class="pl-c1">None</span>:
                <span class="pl-s1">url_prefix</span> <span class="pl-c1">=</span> <span class="pl-s1">blueprint</span>.<span class="pl-s1">url_prefix</span>
            <span class="pl-k">if</span> <span class="pl-s">'url_prefix'</span> <span class="pl-c1">in</span> <span class="pl-s1">options</span>:
                <span class="pl-k">del</span> <span class="pl-s1">options</span>[<span class="pl-s">'url_prefix'</span>]

            <span class="pl-s1">state</span>.<span class="pl-s1">app</span>.<span class="pl-en">register_blueprint</span>(<span class="pl-s1">blueprint</span>, <span class="pl-s1">url_prefix</span>, <span class="pl-c1">**</span><span class="pl-s1">options</span>)
        <span class="pl-s1">self</span>.<span class="pl-en">record</span>(<span class="pl-s1">deferred</span>)</pre></div>
<p dir="auto">On Heroku, we can't add a local config <code class="notranslate">instance/config.py</code> that's not part of the repo. Instead, they support configuration through env vars. Document this pattern.</p>
<p dir="auto"><code class="notranslate">myapp/config.py</code>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="MAIL_USERNAME = os.environ.get('FLASK_MAIL_USERNAME', 'default')
LDAP_PORT = int(os.environ.get('FLASK_LDAP_PORT', 636))"><pre class="notranslate"><span class="pl-v">MAIL_USERNAME</span> <span class="pl-c1">=</span> <span class="pl-s1">os</span>.<span class="pl-s1">environ</span>.<span class="pl-en">get</span>(<span class="pl-s">'FLASK_MAIL_USERNAME'</span>, <span class="pl-s">'default'</span>)
<span class="pl-v">LDAP_PORT</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-s1">os</span>.<span class="pl-s1">environ</span>.<span class="pl-en">get</span>(<span class="pl-s">'FLASK_LDAP_PORT'</span>, <span class="pl-c1">636</span>))</pre></div>