Chinaunix首页 | 论坛 | 博客
  • 博客访问: 599897
  • 博文数量: 60
  • 博客积分: 3993
  • 博客等级: 中校
  • 技术积分: 1572
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 17:08
文章分类

全部博文(60)

文章存档

2012年(7)

2011年(35)

2010年(8)

2009年(7)

2008年(3)

分类: LINUX

2011-12-26 15:36:09

WebOb class webob.Request(environ=None, environ_getter=None, charset=(No Default), unicode_errors=(No Default),decode_param_names=(No Default), **kw)GETLike .str_GET, but may decode values and keysPOSTLike .str_POST, but may decode values and keysResponseClass()Represents a WSGI responseacceptGets and sets and deletes the ‘HTTP_ACCEPT’ key from the environment. For more information on Accept see . Converts it as a MIME Accept.accept_charsetGets and sets and deletes the ‘HTTP_ACCEPT_CHARSET’ key from the environment. For more information on Accept-Charset see . Converts it as a accept header.accept_encodingGets and sets and deletes the ‘HTTP_ACCEPT_ENCODING’ key from the environment. For more information on Accept-Encoding see . Converts it as a accept header.accept_languageGets and sets and deletes the ‘HTTP_ACCEPT_LANGUAGE’ key from the environment. For more information on Accept-Language see . Converts it as a accept header.application_urlThe URL including SCRIPT_NAME (no PATH_INFO or query string)blank

Create a blank request environ (and Request wrapper) with the given path (path should be urlencoded), and any keys from environ.

The path will become path_info, with any query string split off and used.

All necessary keys will be added to the environ, but the values you pass in will take precedence. If you pass in base_url then wsgi.url_scheme, HTTP_HOST, and SCRIPT_NAME will be filled in from that value.

Any extra keyword will be passed to __init__ (e.g., decode_param_names).

bodyReturn the content of the request body.body_file

Access the body of the request (wsgi.input) as a file-like object.

If you set this value, CONTENT_LENGTH will also be updated (either set to -1, 0 if you delete the attribute, or if you set the attribute to a string then the length of the string).

cache_controlGet/set/modify the Cache-Control header (section )call_application(application, catch_exc_info=False)

Call the given WSGI application, returning (status_string, headerlist, app_iter)

Be sure to call app_iter.close() if it’s there.

If catch_exc_info is true, then returns (status_string, headerlist, app_iter, exc_info), where the fourth item may be None, but won’t be if there was an exception. If you don’t do this and there was an exception, the exception will be raised directly.

content_lengthGets and sets and deletes the ‘CONTENT_LENGTH’ key from the environment. For more information on CONTENT_LENGTH see . Converts it as a int.content_typeGets and sets and deletes the ‘CONTENT_TYPE’ key from the environment. For more information on CONTENT_TYPE see.cookiesLike .str_cookies, but may decode values and keyscopy()

Copy the request and environment object.

This only does a shallow copy, except of wsgi.input

copy_body()

Copies the body, in cases where it might be shared with another request object and that is not desired.

This copies the body in-place, either into a StringIO object or a temporary file.

copy_get()Copies the request and environment object, but turning this request into a GET along the way. If this was a POST request (or any other verb) then it becomes GET, and the request body is thrown away.dateGets and sets and deletes the ‘HTTP_DATE’ key from the environment. For more information on Date see . Converts it as a HTTP date.get_response(application, catch_exc_info=False)

Like .call_application(application), except returns a response object with .status, .headers, and .body attributes.

This will use self.ResponseClass to figure out the class of the response object to return.

headersAll the request headers as a case-insensitive dictionary-like object.hostHost name provided in HTTP_HOST, with fall-back to SERVER_NAMEhost_urlThe URL through the host (no path)if_matchGets and sets and deletes the ‘HTTP_IF_MATCH’ key from the environment. For more information on If-Match see. Converts it as a ETag.if_modified_sinceGets and sets and deletes the ‘HTTP_IF_MODIFIED_SINCE’ key from the environment. For more information on If-Modified-Since see . Converts it as a HTTP date.if_none_matchGets and sets and deletes the ‘HTTP_IF_NONE_MATCH’ key from the environment. For more information on If-None-Match see . Converts it as a ETag.if_rangeGets and sets and deletes the ‘HTTP_IF_RANGE’ key from the environment. For more information on If-Range see. Converts it as a IfRange object.if_unmodified_sinceGets and sets and deletes the ‘HTTP_IF_UNMODIFIED_SINCE’ key from the environment. For more information on If-Unmodified-Since see . Converts it as a HTTP date.is_xhr

Returns a boolean if X-Requested-With is present and XMLHttpRequest

Note: this isn’t set by every XMLHttpRequest request, it is only set if you are using a Javascript library that sets it (or you set the header yourself manually). Currently Prototype and jQuery are known to set this header.

make_body_seekable()

This forces environ['wsgi.input'] to be seekable. That is, if it doesn’t have a seek method already, the content is copied into a StringIO or temporary file.

The choice to copy to StringIO is made from self.request_body_tempfile_limit

max_forwardsGets and sets and deletes the ‘HTTP_MAX_FORWARDS’ key from the environment. For more information on Max-Forwards see . Converts it as a int.methodGets and sets and deletes the ‘REQUEST_METHOD’ key from the environment.paramsLike .str_params, but may decode values and keyspathThe path of the request, without host or query stringpath_infoGets and sets and deletes the ‘PATH_INFO’ key from the environment.path_info_peek()Returns the next segment on PATH_INFO, or None if there is no next segment. Doesn’t modify the environment.path_info_pop()

‘Pops’ off the next segment of PATH_INFO, pushing it onto SCRIPT_NAME, and returning the popped segment. Returns None if there is nothing left on PATH_INFO.

Does not return '' when there’s an empty segment (like /path//path); these segments are just ignored.

path_qsThe path of the request, without host but with query stringpath_urlThe URL including SCRIPT_NAME and PATH_INFO, but not QUERY_STRINGpostvarsWraps a decorator, with a deprecation warning or errorpragmaGets and sets and deletes the ‘HTTP_PRAGMA’ key from the environment. For more information on Pragma see .query_stringGets and sets and deletes the ‘QUERY_STRING’ key from the environment.queryvarsWraps a decorator, with a deprecation warning or errorrangeGets and sets and deletes the ‘HTTP_RANGE’ key from the environment. For more information on Range see . Converts it as a Range object.refererGets and sets and deletes the ‘HTTP_REFERER’ key from the environment. For more information on Referer see .referrerGets and sets and deletes the ‘HTTP_REFERER’ key from the environment. For more information on Referer see .relative_url(other_url, to_application=False)

Resolve other_url relative to the request URL.

If to_application is True, then resolve it relative to the URL with only SCRIPT_NAME

remote_addrGets and sets and deletes the ‘REMOTE_ADDR’ key from the environment.remote_userGets and sets and deletes the ‘REMOTE_USER’ key from the environment.remove_conditional_headers(remove_encoding=True, remove_range=True, remove_match=True, remove_modified=True)

Remove headers that make the request conditional.

These headers can cause the response to be 304 Not Modified, which in some cases you may not want to be possible.

This does not remove headers like If-Match, which are used for conflict detection.

schemeGets and sets and deletes the ‘wsgi.url_scheme’ key from the environment.script_nameGets and sets and deletes the ‘SCRIPT_NAME’ key from the environment.server_nameGets and sets and deletes the ‘SERVER_NAME’ key from the environment.server_portGets and sets and deletes the ‘SERVER_PORT’ key from the environment. Converts it as a int.str_GETReturn a MultiDict containing all the variables from the QUERY_STRING.str_POST

Return a MultiDict containing all the variables from a form request. Returns an empty dict-like object for non-form requests.

Form requests are typically POST requests, however PUT requests with an appropriate Content-Type are also supported.

str_cookiesReturn a plain dictionary of cookies as found in the request.str_paramsA dictionary-like object containing both the parameters from the query string and request body.str_postvarsWraps a decorator, with a deprecation warning or errorstr_queryvarsWraps a decorator, with a deprecation warning or errorurlThe full request URL, including QUERY_STRINGurlargs

Return any positional variables matched in the URL.

Takes values from environ['wsgiorg.routing_args']. Systems like routes set this value.

urlvars

Return any named variables matched in the URL.

Takes values from environ['wsgiorg.routing_args']. Systems like routes set this value.

user_agentGets and sets and deletes the ‘HTTP_USER_AGENT’ key from the environment. For more information on User-Agent see.class webob.Response(body=None, status=None, headerlist=None, app_iter=None, request=None, content_type=None,conditional_response=(No Default), **kw)

Represents a WSGI response

accept_rangesGets and sets and deletes they header Accept-Ranges from the headers For more information on Accept-Ranges see.ageGets and sets and deletes they header Age from the headers For more information on Age see . Converts it as a int.allowGets and sets and deletes they header Allow from the headers For more information on Allow see . Converts it as a list.app_iter

Returns the app_iter of the response.

If body was set, this will create an app_iter from that body (a single-item list)

app_iter_range(start, stop)Return a new app_iter built from the response app_iter, that serves up only the given start:stop range.bodyThe body of the response, as a str. This will read in the entire app_iter if necessary.body_fileReturns a file-like object that can be used to write to the body. If you passed in a list app_iter, that app_iter will be modified by writes.cache_controlGet/set/modify the Cache-Control header (section )charsetGet/set the charset (in the Content-Type)conditional_response_app(environ, start_response)

Like the normal __call__ interface, but checks conditional headers:

  • If-Modified-Since (304 Not Modified; only on GET, HEAD)
  • If-None-Match (304 Not Modified; only on GET, HEAD)
  • Range (406 Partial Content; only on GET, HEAD)
content_encodingGets and sets and deletes they header Content-Encoding from the headers For more information on Content-Encoding see.content_languageGets and sets and deletes they header Content-Language from the headers For more information on Content-Language see. Converts it as a list.content_lengthGets and sets and deletes they header Content-Length from the headers For more information on Content-Length see. Converts it as a int.content_locationGets and sets and deletes they header Content-Location from the headers For more information on Content-Location see.content_md5Gets and sets and deletes they header Content-MD5 from the headers For more information on Content-MD5 see .content_rangeGets and sets and deletes they header Content-Range from the headers For more information on Content-Range see. Converts it as a ContentRange object.content_type

Get/set the Content-Type header (or None), without the charset or any parameters.

If you include parameters (or ; at all) when setting the content_type, any existing parameters will be deleted; otherwise they will be preserved.

content_type_paramsReturns a dictionary of all the parameters in the content type.copy()Makes a copy of the responsedateGets and sets and deletes they header Date from the headers For more information on Date see . Converts it as a HTTP date.delete_cookie(key, path='/', domain=None)

Delete a cookie from the client. Note that path and domain must match how the cookie was originally set.

This sets the cookie to the empty string, and max_age=0 so that it should expire immediately.

encode_content(encoding='gzip')Encode the content with the given encoding (only gzip and identity are supported).environGet/set the request environ associated with this response, if any.etagGets and sets and deletes they header ETag from the headers For more information on ETag see .expiresGets and sets and deletes they header Expires from the headers For more information on Expires see . Converts it as a HTTP date.headerlistThe list of response headersheadersThe headers in a dictionary-like objectlast_modifiedGets and sets and deletes they header Last-Modified from the headers For more information on Last-Modified see. Converts it as a HTTP date.location

Retrieve the Location header of the response, or None if there is no header. If the header is not absolute and this response is associated with a request, make the header absolute.

For more information see .

md5_etag(body=None, set_content_md5=False, set_conditional_response=False)

Generate an etag for the response object using an MD5 hash of the body (the body parameter, or self.body if not given)

Sets self.etag If set_content_md5 is True sets self.content_md5 as well If set_conditional_response is True setsself.conditional_response to True

pragmaGets and sets and deletes they header Pragma from the headers For more information on Pragma see .requestReturn the request associated with this response if any.retry_afterGets and sets and deletes they header Retry-After from the headers For more information on Retry-After see . Converts it as a HTTP date or delta seconds.serverGets and sets and deletes they header Server from the headers For more information on Server see .set_cookie(key, value='', max_age=None, path='/', domain=None, secure=None, httponly=False, version=None,comment=None, expires=None)Set (add) a cookie for the responsestatusThe status stringstatus_intThe status as an integerunicode_bodyGet/set the unicode value of the body (using the charset of the Content-Type)unset_cookie(key)Unset a cookie with the given name (remove it from the response). If there are multiple cookies (e.g., two cookies with the same name and different paths or domains), all such cookies will be deleted.varyGets and sets and deletes they header Vary from the headers For more information on Vary see . Converts it as a list.webob.html_escape(s)

HTML-escape a string or object

This converts any non-string objects passed into it to strings (actually, using unicode()). All values returned are non-unicode strings (using &#num; entities for all non-ASCII characters).

None is treated specially, and returns the empty string.

webob.timedelta_to_seconds(td)Converts a timedelta instance to seconds.class webob.FakeCGIBody(vars)update_environclass webob.ResponseBodyFile(response)encodingThe encoding of the file (inherited from response.charset)class webob.AppIterRange(app_iter, start, stop)Wraps an app_iter, returning just a range of byteswebob._rfc_reference(header, section)webob._cgi_FieldStorage__repr__patch(self)

monkey patch for FieldStorage.__repr__

Unbelievely, the default __repr__ on FieldStorage reads the entire file content instead of being sane about it. This is a simple replacement that doesn’t do that

webob.acceptparse class webob.acceptparse.Accept(header_name, header_value)

Represents a generic Accept-* style header.

This object should not be modified. To add items you can use accept_obj + 'accept_thing' to get a new object

best_match(matches, default_match=None)

Returns the best match in the sequence of matches.

The sequence can be a simple sequence, or you can have (match, server_quality) items in the sequence. If you have these tuples then the client quality is multiplied by the server_quality to get a total.

default_match (default None) is returned if there is no intersection.

best_matches(fallback=None)Return all the matches in order of quality, with fallback (if given) at the end.first_match(matches)Returns the first match in the sequences of matches that is allowed. Ignores quality. Returns the first item if nothing else matches; or if you include None at the end of the match list then that will be returned.quality(match)Return the quality of the given match. Returns None if there is no match (not 0).class webob.acceptparse.NilAccept(header_name)

Represents an Accept header with no value.

MasterClass()

Represents a generic Accept-* style header.

This object should not be modified. To add items you can use accept_obj + 'accept_thing' to get a new object

class webob.acceptparse.NoAccept(header_name)class webob.acceptparse.MIMEAccept(header_name, header_value)

Represents the Accept header, which is a list of mimetypes.

This class knows about mime wildcards, like image/*

accept_html()Returns true if any HTML-like type is acceptedclass webob.acceptparse.MIMENilAccept(header_name)MasterClass()

Represents the Accept header, which is a list of mimetypes.

This class knows about mime wildcards, like image/*

webob.acceptparse.parse_accept(value)

Parses an Accept-* style header.

A list of [(value, quality), ...] is returned. quality will be 1 if it was not given.

webob.byterange class webob.byterange.Range(ranges)

Represents the Range header.

This only represents bytes ranges, which are the only kind specified in HTTP. This can represent multiple sets of ranges, but no place else is this multi-range facility supported.

bytes_to_python_ranges

Converts the list-of-ranges from parse_bytes() to a Python-style list of ranges (non-inclusive end points)

In the list of ranges, the last item can be None to indicate that it should go to the end of the file, and the first item can be negative to indicate that it should start from an offset from the end. If you give a length then this will not occur (negative numbers and offsets will be resolved).

If length is given, and any range is not value, then None is returned.

content_range(length)

Works like range_for_length; returns None or a ContentRange object

You can use it like:

response.content_range = req.range.content_range(response.content_length)

Though it’s still up to you to actually serve that content range!

parseParse the header; may return None if header is invalidparse_bytes

Parse a Range header into (bytes, list_of_ranges). Note that the ranges are inclusive (like in HTTP, not like in Python typically).

Will return None if the header is invalid

python_ranges_to_bytes

Converts a Python-style list of ranges to what serialize_bytes expects.

This is the inverse of bytes_to_python_ranges

range_for_length(length)

If there is only one range, and if it is satisfiable by the given length, then return a (begin, end) non-inclusive range of bytes to serve. Otherwise return None

If length is None (unknown length), then the resulting range may be (begin, None), meaning it should be served from that point. If it’s a range with a fixed endpoint we won’t know if it is satisfiable, so this will return None.

satisfiable(length)Returns true if this range can be satisfied by the resource with the given byte length.serialize_bytesTakes the output of parse_bytes and turns it into a headerclass webob.byterange.ContentRange(start, stop, length)

Represents the Content-Range header

This header is start-stop/length, where stop and length can be * (represented as None in the attributes).

parseParse the header. May return None if it cannot parse. webob.cachecontrol

Represents the Cache-Control header

class webob.cachecontrol.exists_property(prop, type=None)Represents a property that either is listed in the Cache-Control header, or is not listed (has no value)class webob.cachecontrol.value_property(prop, default=None, none=None, type=None)

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

class webob.cachecontrol.CacheControl(properties, type)

Represents the Cache-Control header.

By giving a type of 'request' or 'response' you can control what attributes are allowed (some Cache-Control values only apply to requests or responses).

copy()Returns a copy of this object.max_age

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

max_stale

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

min_fresh

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

must_revalidateRepresents a property that either is listed in the Cache-Control header, or is not listed (has no value)no_cache

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

no_storeRepresents a property that either is listed in the Cache-Control header, or is not listed (has no value)no_transformRepresents a property that either is listed in the Cache-Control header, or is not listed (has no value)only_if_cachedRepresents a property that either is listed in the Cache-Control header, or is not listed (has no value)parse

Parse the header, returning a CacheControl object.

The object is bound to the request or response object updates_to, if that is given.

private

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

proxy_revalidateRepresents a property that either is listed in the Cache-Control header, or is not listed (has no value)publicRepresents a property that either is listed in the Cache-Control header, or is not listed (has no value)s_max_age

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

s_maxage

Represents a property that has a value in the Cache-Control header.

When no value is actually given, the value of self.none is returned.

webob.cachecontrol.serialize_cache_control(properties) webob.datastruct

Contains some data structures.

class webob.datastruct.EnvironHeaders(environ)

An object that represents the headers as present in a WSGI environment.

This object is a wrapper (with no internal state) for a WSGI request object, representing the CGI-style HTTP_* keys as a dictionary. Because a CGI environment can only hold one value for each key, this dictionary is single-valued (unlike outgoing headers).

webob.etag

Does parsing of ETag-related headers: If-None-Matches, If-Matches

Also If-Range parsing

class webob.etag.AnyETagRepresents an ETag of , or a missing ETag when matching is ‘safe’class webob.etag.NoETagRepresents a missing ETag when matching is unsafeclass webob.etag.ETagMatcher(etags, weak_etags=())

Represents an ETag request. Supports containment to see if an ETag matches. You can also use etag_matcher.weak_contains(etag) to allow weak ETags to match (allowable for conditional GET requests, but not ranges or other methods).

parseParse this from a header valueclass webob.etag.IfRange(etag=None, date=None)

Parses and represents the If-Range header, which can be an ETag or a date

match(etag=None, last_modified=None)Return True if the If-Range header matches the given etag or last_modifiedmatch_response(response)Return True if this matches the given webob.Response instance.parseParse this from a header value.class webob.etag.NoIfRangeRepresents a missing If-Range header mod:webob.exc

HTTP Exception

This module processes Python exceptions that relate to HTTP exceptions by defining a set of exceptions, all subclasses of HTTPException. Each exception, in addition to being a Python exception that can be raised and caught, is also a WSGI application and webob.Response object.

This module defines exceptions according to RFC 2068 : codes with 100-300 are not really errors; 400’s are client errors, and 500’s are server errors. According to the WSGI specification , the application can call start_response more then once only under two conditions: (a) the response has not yet been sent, or (b) if the second and subsequent invocations of start_response have a valid exc_info argument obtained from sys.exc_info(). The WSGI specification then requires the server or gateway to handle the case where content has been sent and then an exception was encountered.

Exception HTTPException HTTPOk
  • 200 - HTTPOk
  • 201 - HTTPCreated
  • 202 - HTTPAccepted
  • 203 - HTTPNonAuthoritativeInformation
  • 204 - HTTPNoContent
  • 205 - HTTPResetContent
  • 206 - HTTPPartialContent
HTTPRedirection
  • 300 - HTTPMultipleChoices
  • 301 - HTTPMovedPermanently
  • 302 - HTTPFound
  • 303 - HTTPSeeOther
  • 304 - HTTPNotModified
  • 305 - HTTPUseProxy
  • 306 - Unused (not implemented, obviously)
  • 307 - HTTPTemporaryRedirect
HTTPError HTTPClientError
  • 400 - HTTPBadRequest
  • 401 - HTTPUnauthorized
  • 402 - HTTPPaymentRequired
  • 403 - HTTPForbidden
  • 404 - HTTPNotFound
  • 405 - HTTPMethodNotAllowed
  • 406 - HTTPNotAcceptable
  • 407 - HTTPProxyAuthenticationRequired
  • 408 - HTTPRequestTimeout
  • 409 - HTTPConflict
  • 410 - HTTPGone
  • 411 - HTTPLengthRequired
  • 412 - HTTPPreconditionFailed
  • 413 - HTTPRequestEntityTooLarge
  • 414 - HTTPRequestURITooLong
  • 415 - HTTPUnsupportedMediaType
  • 416 - HTTPRequestRangeNotSatisfiable
  • 417 - HTTPExpectationFailed
HTTPServerError
  • 500 - HTTPInternalServerError
  • 501 - HTTPNotImplemented
  • 502 - HTTPBadGateway
  • 503 - HTTPServiceUnavailable
  • 504 - HTTPGatewayTimeout
  • 505 - HTTPVersionNotSupported

References:



webob.exc.no_escape(value)webob.exc.strip_tags(value)class webob.exc.HTTPException(message, wsgi_response)Exception used on pre-Python-2.5, where new-style classes cannot be used as an exception.class webob.exc.WSGIHTTPException(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPError(detail=None, headers=None, comment=None, body_template=None, **kw)

base class for status codes in the 400’s and 500’s

This is an exception which indicates that an error has occurred, and that any work in progress should not be committed. These are typically results in the 400’s and 500’s.

class webob.exc.HTTPRedirection(detail=None, headers=None, comment=None, body_template=None, **kw)

base class for 300’s status code (redirections)

This is an abstract base class for 3xx redirection. It indicates that further action needs to be taken by the user agent in order to fulfill the request. It does not necessarly signal an error condition.

class webob.exc.HTTPOk(detail=None, headers=None, comment=None, body_template=None, **kw)Base class for the 200’s status code (successful responses)class webob.exc.HTTPCreated(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPAccepted(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPNonAuthoritativeInformation(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPNoContent(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPResetContent(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPPartialContent(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPMultipleChoices(detail=None, headers=None, comment=None, body_template=None, location=None,add_slash=False)class webob.exc.HTTPMovedPermanently(detail=None, headers=None, comment=None, body_template=None, location=None,add_slash=False)class webob.exc.HTTPFound(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)class webob.exc.HTTPSeeOther(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)class webob.exc.HTTPNotModified(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPUseProxy(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)class webob.exc.HTTPTemporaryRedirect(detail=None, headers=None, comment=None, body_template=None, location=None,add_slash=False)class webob.exc.HTTPClientError(detail=None, headers=None, comment=None, body_template=None, **kw)

base class for the 400’s, where the client is in error

This is an error condition in which the client is presumed to be in-error. This is an expected problem, and thus is not considered a bug. A server-side traceback is not warranted. Unless specialized, this is a ‘400 Bad Request’

class webob.exc.HTTPBadRequest(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPUnauthorized(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPPaymentRequired(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPForbidden(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPNotFound(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPMethodNotAllowed(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPNotAcceptable(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPProxyAuthenticationRequired(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPRequestTimeout(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPConflict(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPGone(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPLengthRequired(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPPreconditionFailed(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPRequestEntityTooLarge(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPRequestURITooLong(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPUnsupportedMediaType(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPRequestRangeNotSatisfiable(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPExpectationFailed(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPUnprocessableEntity(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPLocked(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPFailedDependency(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPServerError(detail=None, headers=None, comment=None, body_template=None, **kw)

base class for the 500’s, where the server is in-error

This is an error condition in which the server is presumed to be in-error. This is usually unexpected, and thus requires a traceback; ideally, opening a support ticket for the customer. Unless specialized, this is a ‘500 Internal Server Error’

class webob.exc.HTTPInternalServerError(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPNotImplemented(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPBadGateway(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPServiceUnavailable(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPGatewayTimeout(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPVersionNotSupported(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPInsufficientStorage(detail=None, headers=None, comment=None, body_template=None, **kw)class webob.exc.HTTPExceptionMiddleware(application)

Middleware that catches exceptions in the sub-application. This does not catch exceptions in the app_iter; only during the initial calling of the application.

This should be put very close to applications that might raise these exceptions. This should not be applied globally; letting expected exceptions raise through the WSGI stack is dangerous.

webob.headerdict

Represents the response header list as a dictionary-like object.

class webob.headerdict.HeaderDict(*args, **kw)Like a MultiDict, this wraps a list. Keys are normalized for case and whitespace. webob.multidict

Gives a multi-value dictionary object (MultiDict) plus several wrappers

class webob.multidict.MultiDict(*args, **kw)

An ordered dictionary that can have multiple values for each key. Adds the methods getall, getone, mixed, and add to the normal dictionary interface.

add(key, value)Add the key and value, not overwriting any previous value.dict_of_lists()Returns a dictionary where each key is associated with a list of values.from_fieldstorageCreate a dict from a cgi.FieldStorage instancegetall(key)Return a list of all values matching the key (may be an empty list)getone(key)Get one value matching the key, raising a KeyError if multiple values were found.mixed()Returns a dictionary where the values are either single values, or a list of values when a key/value appears more than once in this dictionary. This is similar to the kind of dictionary often used to represent the variables in a web request.view_listCreate a dict that is a view on the given listclass webob.multidict.UnicodeMultiDict(multi=None, encoding=None, errors='strict', decode_keys=False)

A MultiDict wrapper that decodes returned values to unicode on the fly. Decoding is not applied to assigned values.

The key/value contents are assumed to be str/strs or str/FieldStorages (as is returned by the paste.request.parse_ functions).

Can optionally also decode keys when the decode_keys argument is True.

FieldStorage instances are cloned, and the clone’s filename variable is decoded. Its name variable is decoded when decode_keysis enabled.

add(key, value)Add the key and value, not overwriting any previous value.dict_of_lists()Returns a dictionary where each key is associated with a list of values.getall(key)Return a list of all values matching the key (may be an empty list)getone(key)Get one value matching the key, raising a KeyError if multiple values were found.mixed()Returns a dictionary where the values are either single values, or a list of values when a key/value appears more than once in this dictionary. This is similar to the kind of dictionary often used to represent the variables in a web request.class webob.multidict.NestedMultiDict(*dicts)Wraps several MultiDict objects, treating it as one large MultiDictclass webob.multidict.NoVars(reason=None)

Represents no variables; used when no variables are applicable.

This is read-only

webob.statusreasons

Gives status_reasons, a dictionary of HTTP reasons for integer status codes

webob.updatedict

Dict that has a callback on all updates

class webob.updatedict.UpdateDict
阅读(2982) | 评论(0) | 转发(0) |
0

上一篇:2011-12-22

下一篇:[Python]Beaker文档

给主人留下些什么吧!~~