<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
 <title>#67: authkit-2.4-compat.patch - AuthKit - Trac</title><link rel="start" href="/trac/wiki" /><link rel="search" href="/trac/search" /><link rel="help" href="/trac/wiki/TracGuide" /><link rel="stylesheet" href="/trac/chrome/common/css/trac.css" type="text/css" /><link rel="stylesheet" href="/trac/chrome/common/css/diff.css" type="text/css" /><link rel="stylesheet" href="/trac/chrome/common/css/code.css" type="text/css" /><link rel="icon" href="/trac/chrome/common/trac.ico" type="image/x-icon" /><link rel="shortcut icon" href="/trac/chrome/common/trac.ico" type="image/x-icon" /><link rel="up" href="/trac/ticket/67" title="Ticket #67" /><link rel="alternate" href="/trac/attachment/ticket/67/authkit-2.4-compat.patch?format=raw" title="Original Format" type="text/x-diff" /><style type="text/css">
</style>
 <script type="text/javascript" src="/trac/chrome/common/js/trac.js"></script>
</head>
<body>


<div id="banner">

<div id="header"><a id="logo" href="http://trac.edgewall.com/"><img src="/trac/chrome/common/trac_banner.png" width="236" height="73" alt="Trac" /></a><hr /></div>

<form id="search" action="/trac/search" method="get">
 <div>
  <label for="proj-search">Search:</label>
  <input type="text" id="proj-search" name="q" size="10" accesskey="f" value="" />
  <input type="submit" value="Search" />
  <input type="hidden" name="wiki" value="on" />
  <input type="hidden" name="changeset" value="on" />
  <input type="hidden" name="ticket" value="on" />
 </div>
</form>



<div id="metanav" class="nav"><ul><li class="first"><a href="/trac/login">Login</a></li><li><a href="/trac/settings">Settings</a></li><li><a href="/trac/wiki/TracGuide" accesskey="6">Help/Guide</a></li><li class="last"><a href="/trac/about">About Trac</a></li></ul></div>
</div>

<div id="mainnav" class="nav"><ul><li class="first"><a href="/trac/wiki" accesskey="1">Wiki</a></li><li><a href="/trac/timeline" accesskey="2">Timeline</a></li><li><a href="/trac/roadmap" accesskey="3">Roadmap</a></li><li><a href="/trac/browser">Browse Source</a></li><li><a href="/trac/report">View Tickets</a></li><li><a href="/trac/newticket" accesskey="7">New Ticket</a></li><li class="last"><a href="/trac/search" accesskey="4">Search</a></li></ul></div>
<div id="main">




<div id="ctxtnav" class="nav"></div>

<div id="content" class="attachment">


 <h1><a href="/trac/ticket/67">Ticket #67</a>: authkit-2.4-compat.patch</h1>
 <div id="preview">
   


<div class="diff"><ul class="entries"><li class="entry">
  <h2>test/test.py</h2>
  <table class="inline" summary="Differences" cellspacing="0">
   <colgroup><col class="lineno" /><col class="lineno" /><col class="content" /></colgroup>
   <thead><tr>
    <th>old</th>
    <th>new</th>
    <th>&nbsp;</th>
   </tr></thead><tbody><tr><th>98</th><th>98</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; setup_intercept = &#34;403, 702&#34;,</span>&nbsp;</td></tr><tr><th>99</th><th>99</th><td class="l"><span>&nbsp; &nbsp; )</span>&nbsp;</td></tr><tr><th>100</th><th>100</th><td class="l"><span>&nbsp; &nbsp; res = TestApp(app).get('/403', status=401)</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>101</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; assertEqual(res.header('content-type'), 'text/plain')&nbsp;</td></tr><tr><th>&nbsp;</th><th>101</th><td class="r">&nbsp; &nbsp; &nbsp;</td></tr><tr><th>&nbsp;</th><th>102</th><td class="r">&nbsp; &nbsp; # I.E. text/plain; charset=utf8 would be acceptable&nbsp;</td></tr><tr><th>&nbsp;</th><th>103</th><td class="r">&nbsp; &nbsp; assert 'text/plain' in res.header('content-type'), (&nbsp;</td></tr><tr><th>&nbsp;</th><th>104</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &#34;Unexpected: %s&#34; % res.header('content-type'))&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>105</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td></tr></tbody><tbody><tr><th>102</th><th>106</th><td class="l"><span>&nbsp; &nbsp; # XXX Should this keep the original status code or not?</span>&nbsp;</td></tr><tr><th>103</th><th>107</th><td class="l"><span>&nbsp; &nbsp; assertEqual(res.full_status, '401 Unauthorized')</span>&nbsp;</td></tr><tr><th>104</th><th>108</th><td class="l"><span>&nbsp; &nbsp; assert 'This server could not verify that you are authorized' in res</span>&nbsp;</td></tr><tr><th>105</th><th>109</th><td class="l"><span></span>&nbsp;</td></tr><tr><th>106</th><th>110</th><td class="l"><span>&nbsp; &nbsp; res = TestApp(app).get('/702', status=401)</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>107</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; assertEqual(res.header('content-type'), 'text/plain')&nbsp;</td></tr><tr><th>&nbsp;</th><th>111</th><td class="r">&nbsp; &nbsp; assert 'text/plain' in res.header('content-type'), (&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>112</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#34;Unexpected: %s&#34; % res.header('content-type'))&nbsp;</td></tr></tbody><tbody><tr><th>108</th><th>113</th><td class="l"><span>&nbsp; &nbsp; # XXX Should this keep the original status code or not?</span>&nbsp;</td></tr><tr><th>109</th><th>114</th><td class="l"><span>&nbsp; &nbsp; assertEqual(res.full_status, '401 Unauthorized')</span>&nbsp;</td></tr><tr><th>110</th><th>115</th><td class="l"><span>&nbsp; &nbsp; assert 'This server could not verify that you are authorized' in res</span>&nbsp;</td></tr><tr><th>111</th><th>116</th><td class="l"><span></span>&nbsp;</td></tr><tr><th>112</th><th>117</th><td class="l"><span>&nbsp; &nbsp; res = TestApp(app).get('/500', status=500)</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>113</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; assertEqual(res.header('content-type'), 'text/plain')&nbsp;</td></tr><tr><th>&nbsp;</th><th>118</th><td class="r">&nbsp; &nbsp; assert 'text/plain' in res.header('content-type'), (&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>119</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#34;Unexpected: %s&#34; % res.header('content-type'))&nbsp;</td></tr></tbody><tbody><tr><th>114</th><th>120</th><td class="l"><span>&nbsp; &nbsp; assertEqual(res.full_status, '500 Error')</span>&nbsp;</td></tr><tr><th>115</th><th>121</th><td class="l"><span>&nbsp; &nbsp; assert 'Error' in res</span>&nbsp;</td></tr><tr><th>116</th><th>122</th><td class="l"><span>&nbsp; &nbsp; </span>&nbsp;</td></tr><tr><th>117</th><th>123</th><td class="l"><span>&nbsp; &nbsp; res = TestApp(app).get('/401', status=401)</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>118</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; assertEqual(res.header('content-type'), 'text/plain')&nbsp;</td></tr><tr><th>&nbsp;</th><th>124</th><td class="r">&nbsp; &nbsp; assert 'text/plain' in res.header('content-type'), (&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>125</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#34;Unexpected: %s&#34; % res.header('content-type'))&nbsp;</td></tr></tbody><tbody><tr><th>119</th><th>126</th><td class="l"><span>&nbsp; &nbsp; assertEqual(res.full_status, '401 Unauth')</span>&nbsp;</td></tr><tr><th>120</th><th>127</th><td class="l"><span>&nbsp; &nbsp; assert 'Not Authed' in res</span>&nbsp;</td></tr><tr><th>121</th><th>128</th><td class="l"><span>&nbsp; &nbsp; </span>&nbsp;</td></tr><tr><th>122</th><th>129</th><td class="l"><span>def test_fail():</span>&nbsp;</td></tr><tr><th>123</th><th>130</th><td class="l"><span>&nbsp; &nbsp; for app in [basic_app, digest_app, config_app]:</span>&nbsp;</td></tr><tr><th>124</th><th>131</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; res = TestApp(app).get('/private', status=401)</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>125</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; &nbsp; &nbsp; assertEqual(res.header('content-type'),'text/plain')&nbsp;</td></tr><tr><th>&nbsp;</th><th>132</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; assert 'text/plain' in res.header('content-type'), (&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>133</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#34;Unexpected: %s&#34; % res.header('content-type'))&nbsp;</td></tr></tbody><tbody><tr><th>126</th><th>134</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; assertEqual(res.full_status, '401 Unauthorized')</span>&nbsp;</td></tr><tr><th>127</th><th>135</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; #raise Exception(res)</span>&nbsp;</td></tr><tr><th>128</th><th>136</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; assert 'This server could not verify that you are' in res</span>&nbsp;</td></tr></tbody>
  </table>
 </li><li class="entry">
  <h2>authkit/permissions.py</h2>
  <table class="inline" summary="Differences" cellspacing="0">
   <colgroup><col class="lineno" /><col class="lineno" /><col class="content" /></colgroup>
   <thead><tr>
    <th>old</th>
    <th>new</th>
    <th>&nbsp;</th>
   </tr></thead><tbody><tr><th>27</th><th>27</th><td class="l"><span>import logging</span>&nbsp;</td></tr><tr><th>28</th><th>28</th><td class="l"><span>log = logging.getLogger('authkit.permissions')</span>&nbsp;</td></tr><tr><th>29</th><th>29</th><td class="l"><span></span>&nbsp;</td></tr></tbody><tbody class="add"><tr class="first"><th>&nbsp;</th><th>30</th><td class="r"><ins># will be True for Python 2.5+</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>31</th><td class="r"><ins>newstyle_exceptions = issubclass(Exception, object)</ins>&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>32</th><td class="r"><ins></ins>&nbsp;</td></tr></tbody><tbody><tr><th>30</th><th>33</th><td class="l"><span>class AuthKitConfigError(Exception): </span>&nbsp;</td></tr><tr><th>31</th><th>34</th><td class="l"><span>&nbsp; &nbsp; &#34;&#34;&#34;</span>&nbsp;</td></tr><tr><th>32</th><th>35</th><td class="l"><span>&nbsp; &nbsp; Raised when there is a problem with the</span>&nbsp;</td></tr></tbody>
     <tbody class="skipped">
      <tr><th>&hellip;</th><th>&hellip;</th><td>&nbsp;</td></tr>
     </tbody><tbody><tr><th>171</th><th>174</th><td class="l"><span></span>&nbsp;</td></tr><tr><th>172</th><th>175</th><td class="l"><span>&nbsp; &nbsp; def check(self, app, environ, start_response):</span>&nbsp;</td></tr><tr><th>173</th><th>176</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; if 'REMOTE_USER' not in environ:</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>174</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise NotAuthenticatedError('Not Authenticated')&nbsp;</td></tr><tr><th>&nbsp;</th><th>177</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exc = NotAuthenticatedError('Not Authenticated')&nbsp;</td></tr><tr><th>&nbsp;</th><th>178</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if newstyle_exceptions:&nbsp;</td></tr><tr><th>&nbsp;</th><th>179</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise exc&nbsp;</td></tr><tr><th>&nbsp;</th><th>180</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>181</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise exc.exception # see webob.exc for more details&nbsp;</td></tr></tbody><tbody><tr><th>175</th><th>182</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; elif self.accept_empty==False and not environ['REMOTE_USER']:</span>&nbsp;</td></tr></tbody><tbody class="mod"><tr class="first"><th>176</th><th>&nbsp;</th><td class="l">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise NotAuthorizedError('Not Authorized')&nbsp;</td></tr><tr><th>&nbsp;</th><th>183</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exc = NotAuthorizedError('Not Authorized')&nbsp;</td></tr><tr><th>&nbsp;</th><th>184</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if newstyle_exceptions:&nbsp;</td></tr><tr><th>&nbsp;</th><th>185</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise exc&nbsp;</td></tr><tr><th>&nbsp;</th><th>186</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>187</th><td class="r">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise exc.exception # ditto&nbsp;</td></tr></tbody><tbody><tr><th>177</th><th>188</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; return app(environ, start_response)</span>&nbsp;</td></tr><tr><th>178</th><th>189</th><td class="l"><span></span>&nbsp;</td></tr><tr><th>179</th><th>190</th><td class="l"><span>#</span>&nbsp;</td></tr></tbody>
  </table>
 </li><li class="entry">
  <h2>authkit/authenticate/__init__.py</h2>
  <table class="inline" summary="Differences" cellspacing="0">
   <colgroup><col class="lineno" /><col class="lineno" /><col class="content" /></colgroup>
   <thead><tr>
    <th>old</th>
    <th>new</th>
    <th>&nbsp;</th>
   </tr></thead><tbody><tr><th>45</th><th>45</th><td class="l"><span>from multi import MultiHandler, status_checker</span>&nbsp;</td></tr><tr><th>46</th><th>46</th><td class="l"><span>from pkg_resources import iter_entry_points, load_entry_point</span>&nbsp;</td></tr><tr><th>47</th><th>47</th><td class="l"><span>from paste.deploy.converters import asbool</span>&nbsp;</td></tr></tbody><tbody class="rem"><tr class="first last"><th>48</th><th>&nbsp;</th><td class="l"><del>from paste.httpexceptions import HTTPExceptionHandler</del>&nbsp;</td></tr></tbody><tbody><tr><th>49</th><th>48</th><td class="l"><span></span>&nbsp;</td></tr></tbody><tbody class="add"><tr class="first"><th>&nbsp;</th><th>49</th><td class="r"><ins>import paste.httpexceptions</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>50</th><td class="r"><ins>import webob.exc</ins>&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>51</th><td class="r"><ins></ins>&nbsp;</td></tr></tbody><tbody><tr><th>50</th><th>52</th><td class="l"><span>from authkit.authorize import authorize_request</span>&nbsp;</td></tr><tr><th>51</th><th>53</th><td class="l"><span>from authkit.permissions import RemoteUser, no_authkit_users_in_environ, \</span>&nbsp;</td></tr><tr><th>52</th><th>54</th><td class="l"><span>&nbsp; &nbsp; AuthKitConfigError</span>&nbsp;</td></tr></tbody>
     <tbody class="skipped">
      <tr><th>&hellip;</th><th>&hellip;</th><td>&nbsp;</td></tr>
     </tbody><tbody><tr><th>371</th><th>373</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; merged[key.replace('_','.')] = value</span>&nbsp;</td></tr><tr><th>372</th><th>374</th><td class="l"><span>&nbsp; &nbsp; return merged</span>&nbsp;</td></tr><tr><th>373</th><th>375</th><td class="l"><span></span>&nbsp;</td></tr></tbody><tbody class="add"><tr class="first"><th>&nbsp;</th><th>376</th><td class="r"><ins>class HTTPExceptionHandler(object):</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>377</th><td class="r"><ins>&nbsp; &nbsp; &#34;&#34;&#34;</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>378</th><td class="r"><ins>&nbsp; &nbsp; catches exceptions and turns them into proper HTTP responses</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>379</th><td class="r"><ins></ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>380</th><td class="r"><ins>&nbsp; &nbsp; Attributes:</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>381</th><td class="r"><ins></ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>382</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp;``warning_level``</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>383</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;This attribute determines for what exceptions a stack</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>384</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace is kept for lower level reporting; by default, it</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>385</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;only keeps stack trace for 5xx, HTTPServerError exceptions.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>386</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;To keep a stack trace for 4xx, HTTPClientError exceptions,</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>387</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;set this to 400.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>388</th><td class="r"><ins></ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>389</th><td class="r"><ins>&nbsp; &nbsp; This middleware catches any exceptions (which are subclasses of</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>390</th><td class="r"><ins>&nbsp; &nbsp; ``HTTPException``) and turns them into proper HTTP responses.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>391</th><td class="r"><ins>&nbsp; &nbsp; Note if the headers have already been sent, the stack trace is</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>392</th><td class="r"><ins>&nbsp; &nbsp; always maintained as this indicates a programming error.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>393</th><td class="r"><ins></ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>394</th><td class="r"><ins>&nbsp; &nbsp; Note that you must raise the exception before returning the</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>395</th><td class="r"><ins>&nbsp; &nbsp; app_iter, and you cannot use this with generator apps that don't</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>396</th><td class="r"><ins>&nbsp; &nbsp; raise an exception until after their app_iter is iterated over.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>397</th><td class="r"><ins>&nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>398</th><td class="r"><ins>&nbsp; &nbsp; .. note::</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>399</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>400</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; This originally came from paste.httpexceptions.HTTPExceptionHandler</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>401</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; and is patched with comments below for compatibility with </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>402</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; webob + Python 2.4</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>403</th><td class="r"><ins>&nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>404</th><td class="r"><ins>&nbsp; &nbsp; &#34;&#34;&#34;</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>405</th><td class="r"><ins></ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>406</th><td class="r"><ins>&nbsp; &nbsp; def __init__(self, application, warning_level=None):</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>407</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; assert not warning_level or ( warning_level &gt; 99 and</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>408</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; warning_level &lt; 600)</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>409</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; self.warning_level = warning_level or 500</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>410</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; self.application = application</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>411</th><td class="r"><ins></ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>412</th><td class="r"><ins>&nbsp; &nbsp; def __call__(self, environ, start_response):</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>413</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>414</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # Note that catching the webob exception is for Python 2.4 support.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>415</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # In the brave new world of new-style exceptions (derived from object)</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>416</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # multiple inheritance works like you'd expect: the NotAuthenticatedError </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>417</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # is caught because it descends from the past and webob exceptions.</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>418</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; # In the old world (2.4-), the webob exception needs to be in the catch list</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>419</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>420</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; environ['paste.httpexceptions'] = self</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>421</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; environ.setdefault('paste.expected_exceptions',</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>422</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[]).extend([paste.httpexceptions.HTTPException,</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>423</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;webob.exc.HTTPException])</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>424</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; try:</ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>425</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return self.application(environ, start_response)&nbsp; &nbsp; &nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>426</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; except (paste.httpexceptions.HTTPException, </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>427</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; webob.exc.HTTPException), exc:&nbsp; &nbsp; &nbsp; &nbsp; </ins>&nbsp;</td></tr><tr><th>&nbsp;</th><th>428</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return exc(environ, start_response)</ins>&nbsp;</td></tr><tr class="last"><th>&nbsp;</th><th>429</th><td class="r"><ins></ins>&nbsp;</td></tr></tbody><tbody><tr><th>374</th><th>430</th><td class="l"><span>def middleware(app, app_conf=None, global_conf=None, prefix='authkit.', </span>&nbsp;</td></tr><tr><th>375</th><th>431</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;handle_httpexception=True, middleware=None, **options):&nbsp; &nbsp;</span>&nbsp;</td></tr><tr><th>376</th><th>432</th><td class="l"><span>&nbsp; &nbsp; &#34;&#34;&#34;</span>&nbsp;</td></tr></tbody>
  </table>
 </li>
</ul></div>

 </div>
 


</div>
<script type="text/javascript">searchHighlight()</script>
<div id="altlinks"><h3>Download in other formats:</h3><ul><li class="first last"><a href="/trac/attachment/ticket/67/authkit-2.4-compat.patch?format=raw">Original Format</a></li></ul></div>

</div>

<div id="footer">
 <hr />
 <a id="tracpowered" href="http://trac.edgewall.com/"><img src="/trac/chrome/common/trac_logo_mini.png" height="30" width="107"
   alt="Trac Powered"/></a>
 <p class="left">
  Powered by <a href="/trac/about"><strong>Trac 0.9.3</strong></a><br />
  By <a href="http://www.edgewall.com/">Edgewall Software</a>.
 </p>
 <p class="right">
  Visit the Trac open source project at<br /><a href="http://trac.edgewall.com/">http://trac.edgewall.com/</a>
 </p>
</div>



 </body>
</html>

