<p dir="auto">it would be nice if there was a way to generate extra data before dispatching to a module</p>
<p dir="auto">something like this (bad example to get the idea across)</p>
<pre class="notranslate">@app.route('//wiki', module=vcswiki)
def user_wiki(username):
    g.wiki = get_wiki_for_user(username)

@app.route('/help', module=vcswiki)
def help_wiki():
    g.wiki = get_help_wiki()
</pre>
<p dir="auto">The module branch support variable modules.  Something like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="wiki = Module(__name__, url_prefix='/&lt;user&gt;')"><pre class="notranslate"><code class="notranslate">wiki = Module(__name__, url_prefix='/&lt;user&gt;')
</code></pre></div>
<p dir="auto">Then each function registered is passed 'user' as first parameter.  This already works as far as I can see, however it would be better if that value can be attached to <code class="notranslate">g</code> instead.  What should work (not tested) is this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@wiki.before_request
def attach_user():
    g.wiki_user = request.view_args.pop('user', None)"><pre class="notranslate"><code class="notranslate">@wiki.before_request
def attach_user():
    g.wiki_user = request.view_args.pop('user', None)
</code></pre></div>
<p dir="auto">The problem with this is that URLs generated still need that user attached, so <code class="notranslate">url_for</code> needs some kind of support for that.  However I am not entirely sure how that should look like.</p>