circuits.web.utils module¶
Utilities
This module implements utility functions.
-
circuits.web.utils.
average
(xs)¶
-
circuits.web.utils.
variance
(xs)¶
-
circuits.web.utils.
stddev
(xs)¶
-
circuits.web.utils.
parse_body
(request, response, params)¶
-
circuits.web.utils.
parse_qs
(query_string) → dict¶ Build a params dictionary from a query_string. If keep_blank_values is True (the default), keep values that are blank.
-
circuits.web.utils.
dictform
(form)¶
-
circuits.web.utils.
compress
(body, compress_level)¶ Compress ‘body’ at the given compress_level.
-
circuits.web.utils.
get_ranges
(headervalue, content_length)¶ Return a list of (start, stop) indices from a Range header, or None.
Each (start, stop) tuple will be composed of two ints, which are suitable for use in a slicing operation. That is, the header “Range: bytes=3-6”, if applied against a Python string, is requesting resource[3:7]. This function will return the list [(3, 7)].
If this function returns an empty list, you should return HTTP 416.
-
class
circuits.web.utils.
IOrderedDict
(*args, **kwds)¶ Bases:
dict
,_abcoll.MutableMapping
Dictionary that remembers insertion order with insensitive key
Initialize an ordered dictionary. Signature is the same as for regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary.
-
clear
() → None. Remove all items from od.¶
-
get
(key, default=None)¶
-
setdefault
(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶
-
update
([E, ]**F) → None. Update D from mapping/iterable E and F.¶ If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
-
pop
(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, d is returned if given, otherwise KeyError is raised.
-
keys
() → list of D's keys¶
-
values
() → list of D's values¶
-
items
() → list of D's (key, value) pairs, as 2-tuples¶
-
popitem
() → (k, v), return and remove a (key, value) pair.¶ Pairs are returned in LIFO order if last is true or FIFO order if false.
-
copy
() → a shallow copy of od¶
-
classmethod
fromkeys
(S[, v]) → New ordered dictionary with keys from S¶ and values equal to v (which defaults to None).
-
-
circuits.web.utils.
is_ssl_handshake
(buf)¶ Detect an SSLv2 or SSLv3 handshake