title: Google App Engine: status code 403
body: <p>How can I response a 403 status code?</p>
  
  <p>I was following some example which had this: <code>raise webapp.Error(403)</code>. So I thought that this would give me a 403 but it just gives me a regular 500 server error instead.</p>
  
  <p>This is complete example:</p>
  
  <pre><code>def administrator(method):
      ''' credit: 
          http://github.com/btbytes/teh/blob/master/utils.py 
  
          decorator to restrict access to admin areas
      '''
      @functools.wraps(method)
      def wrapper(self, *args, **kwargs):
          user = users.get_current_user()
          if not user:
              if self.request.method == "GET":
                  self.redirect(users.create_login_url(self.request.uri))
                  return
          if not users.is_current_user_admin():
              raise webapp.Error(403)
          else:
              return method(self, *args, **kwargs)
      return wrapper
  </code></pre>
  
  <p>This is where I got it: <a href="http://bitbucket.org/abernier/yab/src/tip/handlers/admin.py" rel="nofollow noreferrer">http://bitbucket.org/abernier/yab/src/tip/handlers/admin.py</a></p>