<div><br></div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ 原始邮件 ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>发件人:</b> "夏天的风";<langslike@foxmail.com>;</div><div><b>发送时间:</b> 2016年1月19日(星期二) 下午3:47</div><div><b>收件人:</b> "flask-request"<flask-request@python.org>; <wbr></div><div></div><div><b>主题:</b> help on request.view_args</div></div><div><br></div><div>Hi</div><div>I'm reading some web application code using flask, and the variable <span class="n" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 15px; line-height: 1.3; white-space: pre-wrap; widows: auto;">request</span><span class="o" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 15px; line-height: 1.3; white-space: pre-wrap; widows: auto; color: rgb(88, 40, 0);">.</span><span class="n" style="font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 15px; line-height: 1.3; white-space: pre-wrap; widows: auto;">view_args confuses me: the url http://**?a=1 means that the associated request.args['a'] will be 1, how about view_args? how to set view_args for a request? and what's the general purpose of using it? I read the flask documentation ,but the description is too short .I googled but found most of the usage of view_args deals with pagination: </span></div><div>http://flask.pocoo.org/snippets/44/</div><div><pre style="font-size: 15px; padding: 7px 30px; margin: 15px -30px; line-height: 1.3; widows: auto; font-family: Consolas, Menlo, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace !important; background: rgb(238, 238, 238);"><span class="k" style="color: rgb(0, 68, 97); font-weight: bold;">def</span> <span class="nf">url_for_other_page</span><span class="p" style="font-weight: bold;">(</span><span class="n">page</span><span class="p" style="font-weight: bold;">):</span>
    <span class="n">args</span> <span class="o" style="color: rgb(88, 40, 0);">=</span> <span class="n">request</span><span class="o" style="color: rgb(88, 40, 0);">.</span><span class="n">view_args</span><span class="o" style="color: rgb(88, 40, 0);">.</span><span class="n">copy</span><span class="p" style="font-weight: bold;">()</span>
    <span class="n">args</span><span class="p" style="font-weight: bold;">[</span><span class="s" style="color: rgb(78, 154, 6);">'page'</span><span class="p" style="font-weight: bold;">]</span> <span class="o" style="color: rgb(88, 40, 0);">=</span> <span class="n">page</span>
    <span class="k" style="color: rgb(0, 68, 97); font-weight: bold;">return</span> <span class="n">url_for</span><span class="p" style="font-weight: bold;">(</span><span class="n">request</span><span class="o" style="color: rgb(88, 40, 0);">.</span><span class="n">endpoint</span><span class="p" style="font-weight: bold;">,</span> <span class="o" style="color: rgb(88, 40, 0);">**</span><span class="n">args</span><span class="p" style="font-weight: bold;">)</span>
<span class="n">app</span><span class="o" style="color: rgb(88, 40, 0);">.</span><span class="n">jinja_env</span><span class="o" style="color: rgb(88, 40, 0);">.</span><span class="n">globals</span><span class="p" style="font-weight: bold;">[</span><span class="s" style="color: rgb(78, 154, 6);">'url_for_other_page'</span><span class="p" style="font-weight: bold;">]</span> <span class="o" style="color: rgb(88, 40, 0);">=</span> <span class="n">url_for_other_page</span></pre></div></div>