Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Properties
MoinMoin.support.werkzeug.exceptions.MethodNotAllowed Class Reference
Inheritance diagram for MoinMoin.support.werkzeug.exceptions.MethodNotAllowed:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.werkzeug.exceptions.MethodNotAllowed:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def get_headers
def get_description
def wrap
def name
def get_body
def get_response
def __call__

Public Attributes

 valid_methods

Static Public Attributes

int code = 405
 description = None
tuple wrap = classmethod(wrap)

Properties

 name = property(name, doc=name.__doc__)

Detailed Description

*405* `Method Not Allowed`

Raise if the server used a method the resource does not handle.  For
example `POST` if the resource is view only.  Especially useful for REST.

The first argument for this exception should be a list of allowed methods.
Strictly speaking the response would be invalid if you don't provide valid
methods in the header which you can do with that list.

Definition at line 210 of file exceptions.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.exceptions.MethodNotAllowed.__init__ (   self,
  valid_methods = None,
  description = None 
)
Takes an optional list of valid http methods
starting with werkzeug 0.3 the list will be mandatory.

Definition at line 222 of file exceptions.py.

00222 
00223     def __init__(self, valid_methods=None, description=None):
00224         """Takes an optional list of valid http methods
00225         starting with werkzeug 0.3 the list will be mandatory."""
00226         HTTPException.__init__(self, description)
00227         self.valid_methods = valid_methods


Member Function Documentation

def MoinMoin.support.werkzeug.exceptions.HTTPException.__call__ (   self,
  environ,
  start_response 
) [inherited]
Call the exception as WSGI application.

:param environ: the WSGI environment.
:param start_response: the response callable provided by the WSGI
               server.

Definition at line 132 of file exceptions.py.

00132 
00133     def __call__(self, environ, start_response):
00134         """Call the exception as WSGI application.
00135 
00136         :param environ: the WSGI environment.
00137         :param start_response: the response callable provided by the WSGI
00138                                server.
00139         """
00140         response = self.get_response(environ)
00141         return response(environ, start_response)
00142 

Here is the call graph for this function:

def MoinMoin.support.werkzeug.exceptions.HTTPException.get_body (   self,
  environ 
) [inherited]
Get the HTML body.

Definition at line 101 of file exceptions.py.

00101 
00102     def get_body(self, environ):
00103         """Get the HTML body."""
00104         return (
00105             '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
00106             '<title>%(code)s %(name)s</title>\n'
00107             '<h1>%(name)s</h1>\n'
00108             '%(description)s\n'
00109         ) % {
00110             'code':         self.code,
00111             'name':         escape(self.name),
00112             'description':  self.get_description(environ)
00113         }

Here is the call graph for this function:

Here is the caller graph for this function:

Get the description.

Reimplemented from MoinMoin.support.werkzeug.exceptions.HTTPException.

Definition at line 234 of file exceptions.py.

00234 
00235     def get_description(self, environ):
00236         m = escape(environ.get('REQUEST_METHOD', 'GET'))
00237         return '<p>The method %s is not allowed for the requested URL.</p>' % m
00238 

Get a list of headers.

Reimplemented from MoinMoin.support.werkzeug.exceptions.HTTPException.

Definition at line 228 of file exceptions.py.

00228 
00229     def get_headers(self, environ):
00230         headers = HTTPException.get_headers(self, environ)
00231         if self.valid_methods:
00232             headers.append(('Allow', ', '.join(self.valid_methods)))
00233         return headers

def MoinMoin.support.werkzeug.exceptions.HTTPException.get_response (   self,
  environ 
) [inherited]
Get a response object.

:param environ: the environ for the request.
:return: a :class:`BaseResponse` object or a subclass thereof.

Reimplemented in MoinMoin.support.werkzeug.exceptions._ProxyException.

Definition at line 118 of file exceptions.py.

00118 
00119     def get_response(self, environ):
00120         """Get a response object.
00121 
00122         :param environ: the environ for the request.
00123         :return: a :class:`BaseResponse` object or a subclass thereof.
00124         """
00125         # lazyly imported for various reasons.  For one can use the exceptions
00126         # with custom responses (testing exception instances against types) and
00127         # so we don't ever have to import the wrappers, but also because there
00128         # are ciruclar dependencies when bootstrapping the module.
00129         from werkzeug.wrappers import BaseResponse
00130         headers = self.get_headers(environ)
00131         return BaseResponse(self.get_body(environ), self.code, headers)

Here is the call graph for this function:

Here is the caller graph for this function:

The status name.

Definition at line 92 of file exceptions.py.

00092 
00093     def name(self):
00094         """The status name."""
        return HTTP_STATUS_CODES[self.code]
def MoinMoin.support.werkzeug.exceptions.HTTPException.wrap (   cls,
  exception,
  name = None 
) [inherited]
This method returns a new subclass of the exception provided that
also is a subclass of `BadRequest`.

Definition at line 78 of file exceptions.py.

00078 
00079     def wrap(cls, exception, name=None):
00080         """
00081         This method returns a new subclass of the exception provided that
00082         also is a subclass of `BadRequest`.
00083         """
00084         class newcls(cls, exception):
00085             def __init__(self, arg=None, description=None):
00086                 cls.__init__(self, description)
00087                 exception.__init__(self, arg)
00088         newcls.__module__ = sys._getframe(1).f_globals.get('__name__')
00089         newcls.__name__ = name or cls.__name__ + exception.__name__
        return newcls

Here is the call graph for this function:


Member Data Documentation

Reimplemented from MoinMoin.support.werkzeug.exceptions.HTTPException.

Definition at line 220 of file exceptions.py.

Definition at line 226 of file exceptions.py.

tuple MoinMoin.support.werkzeug.exceptions.HTTPException.wrap = classmethod(wrap) [static, inherited]

Definition at line 90 of file exceptions.py.


Property Documentation

MoinMoin.support.werkzeug.exceptions.HTTPException.name = property(name, doc=name.__doc__) [static, inherited]

Definition at line 95 of file exceptions.py.


The documentation for this class was generated from the following file: