wasp_general.network.web package¶
Submodules¶
wasp_general.network.web.cookies module¶
Bases:
objectThis class represent a single HTTP Cookie as it is described in RFC 6265. Call
WHTTPCookie.ro()method to create unchangeable cookie copyReturn attribute value. Attribute value can be updated with this method. In order to update attribute value attr_value must be set. Cookie attribute value couldn’t be changed if cookie is in read-only mode (RuntimeError exception is raised).
Parameters: - attr_name – target attribute name
- attr_value – new value to set
Returns: str
Return cookie attributes as dictionary, where keys are attribute names and values are their values
Returns: dict
Check cookie attribute value for validity. Return True if value is valid
Parameters: - attr_name – attribute name to check
- attr_value – attribute value to check
Returns: bool
Dictionary of valid attribute names and appropriate values regexp
Check cookie name for validity. Return True if name is valid
Parameters: cookie_name – name to check Returns: bool
Check for non-acceptable cookie name
see RFC 6265, Section 4.1.1
Check cookie value for validity. Return True if value is valid
Parameters: cookie_value – value to check Returns: bool
Check for non-acceptable cookie value
see RFC 6265, Section 4.1.1
Return copy
Returns: WHTTPCookie
Return cookie name
Returns: str
Remove cookie attribute. Cookie attribute couldn’t be removed if cookie is in read-only mode (RuntimeError exception is raised).
Parameters: attr_name – name of attribute to remove Returns: None
Return read-only copy
Returns: WHTTPCookie
Return cookie value. Cookie value can be updated, when new_value is not None. Cookie value couldn’t be changed if cookie is in read-only mode (RuntimeError exception is raised).
Parameters: new_value – new value to set Returns: str
Bases:
objectClass represent collection of cookies. Call
WHTTPCookieJar.ro()method to create read-only copy (in this state no changes are allowed)Add new cookie (or replace if there is cookie with the same name already)
Parameters: cookie – cookie to add Returns: None
Return available cookie names
Returns: tuple of str
Create cookie jar from HTTP Header text like ‘Set-Cookie: cookie=value’
Parameters: cookie_text – http header code Returns: WHTTPCookieJar
Create cookie jar from SimpleCookie object
Parameters: simple_cookie – cookies to import Returns: WHTTPCookieJar
Remove cookie by its name
Parameters: cookie_name – cookie name Returns:
Return read-only copy
Returns: WHTTPCookieJar
wasp_general.network.web.debug module¶
-
class
wasp_general.network.web.debug.WWebDebugInfo[source]¶ Bases:
objectThis is API prototype for web-service debugging process
-
exception(session_id, exc)[source]¶ Dump raised exception (may be called more then once)
Parameters: - session_id – session origin
- exc – raised exception
Returns: None
-
finalize(session_id)[source]¶ Client session finalization. This method is called whenever exceptions were risen or not
Parameters: session_id – session origin Returns: None
-
request(session_id, request, protocol_version, protocol)[source]¶ Dump client request
Parameters: - session_id – session origin
- request – client request
- protocol_version – client protocol version (like 0.9/1.0/1.1/2)
- protocol – client protocol (like http/https)
Returns: None
-
wasp_general.network.web.headers module¶
-
class
wasp_general.network.web.headers.WHTTPHeaders(**kwargs)[source]¶ Bases:
objectRepresent HTTP Headers as they are described in RFC 1945. Call
WHTTPHeaders.ro()method to create read-only copy (in this state no changes are allowed)Cookies that are stored with
WHTTPHeaders.set_cookie_jar()method have highest priority than cookies stored within constructor and/orWHTTPHeaders.add_header(). So in the conflict situation cookies saved withinWHTTPHeaders.set_cookie_jar()must be used.Cookies that are stored in
WHTTPHeaders.client_cookie_jar()are client cookies (i.e. read-only cookies).-
add_headers(header_name, value, *values)[source]¶ Add new header
Parameters: - header_name – name of the header to add
- value – header value
- values – additional header values (in a result request/response must be concatenated by the coma or by the separate header string)
Returns: None
Return internal cookie jar that must be used as HTTP-request cookies
see
WHTTPCookieJarReturns: WHTTPCookieJar
-
content_type(value=None)[source]¶ Set (replace) and or get “Content-Type” header value
Parameters: value – value to set (if specified) Returns: None if header doesn’t exist, otherwise - str
-
get_headers(header_name)[source]¶ Return header value by its name
Parameters: header_name – header name Returns: tuple of str
-
static
header_name_check(header_name)[source]¶ Check header name for validity. Return True if name is valid
Parameters: header_name – name to check Returns: bool
-
header_name_re= re.compile(b'[^\x00-\x1e\x7f()<>@,;:\\\\"/\\[\\]?={} \t]+')¶ Regexp is for HTTP header name checking
-
classmethod
import_headers(http_code)[source]¶ Create WHTTPHeaders by the given code. If code has ‘Set-Cookie’ headers, that headers are parsed, data are stored in internal cookie jar. At the end of parsing ‘Set-Cookie’ headers are removed from the result
Parameters: http_code – HTTP code to parse Returns: WHTTPHeaders
-
normalize_name(header_name)[source]¶ Return header name as it is recommended (required) by corresponding http protocol. For protocol switching use
WHTTPHeaders.switch_name_style()method.All current available protocols (0.9-2) compare header names in a case-insensitive fashion. However, previous protocol versions (0.9-1.1) recommends to use camel-case names like Foo or Foo-Bar. But HTTP/2 (RFC 7540) strictly requires lowercase only header names.
Parameters: header_name – name to convert Returns: str
-
remove_headers(header_name)[source]¶ Remove header by its name
Parameters: header_name – name of header to remove Returns: None
-
replace_headers(header_name, value, *values)[source]¶ Replace header value with specified value and/or values
Parameters: - header_name – target header
- value – new header value
- values – additional header values (in a result request/response must be concatenated by the coma or by the separate header string)
Returns: None
Return internal cookie jar that must be used for HTTP-response
see
WHTTPCookieJarReturns: WHTTPCookieJar
-
switch_name_style(http_protocol_version)[source]¶ Return object copy with header names saved as it is described in the given protocol version
see
WHTTPHeaders.normalize_name()Parameters: http_protocol_version – target HTTP protocol version Returns: WHTTPHeaders
-
wasp_general.network.web.proto module¶
-
class
wasp_general.network.web.proto.WWebErrorPresenter(request)[source]¶ Bases:
wasp_general.network.web.proto.WWebPresenterPresenter which is used for displaying standard HTTP-errors and internal exceptions
-
class
wasp_general.network.web.proto.WWebPresenter(request)[source]¶ Bases:
objectClass represent worker that generates response over specified request. WWebTargetRouteProto defines what exactly method will be called and with what arguments.
-
class
wasp_general.network.web.proto.WWebPresenterCollectionProto[source]¶ Bases:
objectRepresent collection of presenters
see
WWebPresenter
-
class
wasp_general.network.web.proto.WWebPresenterFactoryProto[source]¶ Bases:
objectThis class is used for presenter object instantiation. Different presenter classes may have different constructor and so may require different arguments, so this class implementation will be possible to instantiate limited presenter classes. Because of that, this class is tightly connected with specific WWebServiceProto implementation, which uses this class for creating presenter
-
instantiable(presenter_class)[source]¶ Check if this factory can produce the specified presenter
Parameters: presenter_class – target presenter class Returns: bool
-
instantiate(presenter_class, *args, **kwargs)[source]¶ Create new presenter object. Different implementation may have different required arguments
Parameters: - presenter_class – presenter class to instantiate
- args – instantiation arguments (may vary)
- kwargs – instantiation arguments (may vary)
Returns: WWebPresenter
-
-
class
wasp_general.network.web.proto.WWebRequestProto[source]¶ Bases:
objectClass represent client HTTP-request
-
content_type()[source]¶ Return request content_type (“Content-Type” header value)
Returns: None or str
-
get_vars()[source]¶ Parse request path and return GET-vars
Returns: None or dictionary of names and tuples of values
-
get_vars_re= re.compile("\\?([a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?]+)(#[a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?]*)?$")¶ Regular expression that is used for GET-vars parsing
-
post_vars()[source]¶ Parse request payload and return POST-vars
Returns: None or dictionary of names and tuples of values
-
post_vars_re= re.compile("([a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?]+)")¶ Regular expression that is used for POST-vars parsing
-
-
class
wasp_general.network.web.proto.WWebResponseProto[source]¶ Bases:
objectClass represent server response for client HTTP-request
-
class
wasp_general.network.web.proto.WWebRouteMapProto[source]¶ Bases:
objectRepresent collection of routes
-
error_presenter()[source]¶ Return presenter that is used for error handling
Returns: WWebErrorPresenter
-
-
class
wasp_general.network.web.proto.WWebServiceProto[source]¶ Bases:
objectRepresent service that unites wasp-general web-functionality
-
class
wasp_general.network.web.proto.WWebSessionProto[source]¶ Bases:
objectRepresent client session. For HTTP/0.9-1.0 every request creates new session. For HTTP/1.1 request can be joined in a single session if “Connection” header is used. For HTTP/2 protocol there can be single session for every client
-
protocol_version()[source]¶ Return currently used protocol version
Returns: str (one of “0.9”/”1.0”/”1.1”/”2”)
-
wasp_general.network.web.re_statements module¶
Represent valid Domain attribute value of cookie
see RFC 6265, Section 5.2.3 external usage:
WHTTPCookie
Represent valid Expires attribute value of cookie
see RFC 6265, Section 5.2.1 external usage:
WHTTPCookie
Represent valid HttpOnly attribute value of cookie
see RFC 6265, Section 5.2.6 external usage:
WHTTPCookie
Represent valid Max-Age attribute value of cookie
see RFC 6265, Section 5.2.2 external usage:
WHTTPCookie
Represent valid Secure attribute value of cookie
see RFC 6265, Section 5.2.5 external usage:
WHTTPCookie
-
wasp_general.network.web.re_statements.http_get_vars_selection= "\\?([a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?]+)(#[a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?]*)?$"¶ Allow to select variables (GET-variables) and fragment code from URI
see RFC 2616, Section 3.4 external usage:
WWebRequestProto
-
wasp_general.network.web.re_statements.http_header_name= b'[^\x00-\x1e\x7f()<>@,;:\\\\"/\\[\\]?={} \t]+'¶ Represent valid HTTP header name.
see RFC 1945, Section 4.2 external usage:
WHTTPHeaders
-
wasp_general.network.web.re_statements.http_method_name= 'GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE'¶ Represent valid HTTP method. This regexp has as strict restriction as HTTP/2 (RFC 7231) does.
see RFC 1945, Section 5.1.1. RFC 2616, Section 5.1.1, RFC 7231, Section 4.1
external usage:
WWebRequest
-
wasp_general.network.web.re_statements.http_path= '/[a-zA-Z0-9_\\-.~%:/?#\\[\\]@!$&\'()*+,;="]*'¶ Represent valid requested URI
for URI see RFC 3986, Section 3 external usage:
WWebRequest,WHTTPCookie
-
wasp_general.network.web.re_statements.http_path_alphabet= 'a-zA-Z0-9_\\-.~%:/?#\\[\\]@!$&\'()*+,;="'¶ Represent valid set of chars, that URI can have
for URI see RFC 3986, Section 3
-
wasp_general.network.web.re_statements.http_post_vars_selection= "([a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?]+)"¶ Allow to select variables that are given as ‘application/x-www-form-urlencoded’.
see RFC 1867 external usage:
WWebRequestProto
-
wasp_general.network.web.re_statements.http_version= '0\\.9|1\\.0|1\\.1'¶ Represent valid requested HTTP-versions
see RFC 2616, Section 3.1
-
wasp_general.network.web.re_statements.uri_fragment_alphabet= "a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?"¶ Represent valid set of chars, that fragment can have it in URI
see RFC 2616, Section 3.1
-
wasp_general.network.web.re_statements.uri_query_alphabet= "a-zA-Z0-9\\-._~%!$&'()*+,;=:@/?"¶ Represent valid set of chars, that query can have it in URI
see RFC 2616, Section 3.1
-
wasp_general.network.web.re_statements.wasp_presenter_name_alphabet= 'a-zA-Z0-9_.\\-'¶ Represent valid set of chars, that presenter name can have
-
wasp_general.network.web.re_statements.wasp_presenter_name_selection= '([a-zA-Z][a-zA-Z0-9_.\\-]*)'¶ Allow to select presenter name
-
wasp_general.network.web.re_statements.wasp_route_arg_name= '[a-zA-Z][a-zA-Z0-9_]*'¶ Represent valid name for route argument name
external usage:
WWebRouteMap
-
wasp_general.network.web.re_statements.wasp_route_arg_name_selection= '\\{([a-zA-Z][a-zA-Z0-9_]*)\\}'¶ Represent simple route argument pattern
external usage:
WWebRoute.BasicArgSearch
-
wasp_general.network.web.re_statements.wasp_route_arg_value_selection= '([a-zA-Z0-9_\\-.~%:\\[\\]@!$&\'()*+;="]+)'¶ Allow to select route argument from a requested URI
external usage:
WWebRoute.BasicArgSearch
-
wasp_general.network.web.re_statements.wasp_route_custom_arg_selection= '(\\{([a-zA-Z][a-zA-Z0-9_]*) *: *"([^"]+)"\\})'¶ Allow to select custom route argument name and argument pattern from URI pattern
external usage:
WWebRoute.CustomArgSearch
-
wasp_general.network.web.re_statements.wasp_route_custom_arg_value_pattern= '[^"]'¶ Represent custom route argument pattern
-
wasp_general.network.web.re_statements.wasp_route_import_pattern= '^\\s*([a-zA-Z0-9_\\-.~%:/?#\\[\\]@!$&\'()*+,;="\\{\\}\\\\]+) +=> +([a-zA-Z][a-zA-Z0-9_.\\-]*)( +\\((.*)\\))?\\s*$'¶ Allow to parse custom route from a imported text
external usage:
WWebRouteMap
-
wasp_general.network.web.re_statements.wasp_route_uri_pattern_alphabet= 'a-zA-Z0-9_\\-.~%:/?#\\[\\]@!$&\'()*+,;="\\{\\}\\\\'¶ Represent valid set of chars, that route URI pattern can have
wasp_general.network.web.request module¶
-
class
wasp_general.network.web.request.WWebRequest(session, method, path, headers=None, request_data=None)[source]¶ Bases:
wasp_general.network.web.proto.WWebRequestProtoWWebRequestProtoimplementation. Class represent HTTP-request descriptor. CallWWebRequest.ro()method to create unchangeable copy-
parse_headers(http_code)[source]¶ Parse http-code (like ‘Header-X: foo Header-Y: bar ‘) and retrieve (save) HTTP-headers
param http_code: code to parse return: None
-
classmethod
parse_request_line(session, request_line)[source]¶ Parse given request line like ‘GET /foo’ or ‘POST /zzz HTTP/1.0’
Parameters: - session – origin session
- request_line – line to parse
Returns: WWebRequest
-
request_line_re= re.compile('^(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE) +(/[a-zA-Z0-9_\\-.~%:/?#\\[\\]@!$&\'()*+,;="]*)( +HTTP/(0\\.9|1\\.0|1\\.1))?$')¶ Check for HTTP request line. See RFC 2616, Section 5.1
-
wasp_general.network.web.response module¶
-
class
wasp_general.network.web.response.WWebResponse(status=None, headers=None, response_data=None)[source]¶ Bases:
wasp_general.network.web.proto.WWebResponseProtoSimple
WWebResponseProtoimplementation-
headers()[source]¶ WWebResponseProto.headers()method implementation
-
response_data()[source]¶ WWebResponseProto.response_data()method implementation
-
status()[source]¶ WWebResponseProto.status()method implementation
-
wasp_general.network.web.service module¶
-
class
wasp_general.network.web.service.WSimpleErrorPresenter(request)[source]¶ Bases:
wasp_general.network.web.proto.WWebErrorPresenterSimple
WWebErrorPresenterimplementation-
error_code(code)[source]¶ WWebErrorPresenter.error_code()method implementation
-
exception_error(exception)[source]¶ WWebErrorPresenter.exception_error()method implementation
-
-
class
wasp_general.network.web.service.WSimplePresenterCollection[source]¶ Bases:
wasp_general.network.web.proto.WWebPresenterCollectionProtoThis is a simple presenter collection
WWebPresenterCollectionProtoimplementation-
add(presenter)[source]¶ Add presenter to this collection
Parameters: presenter – presenter to add Returns: None
-
has(presenter_name)[source]¶ WWebPresenterCollectionProto.has()method implementation
-
presenter(presenter_name)[source]¶ WWebPresenterCollectionProto.presenter()method implementation
-
-
class
wasp_general.network.web.service.WWebEnhancedPresenter(request, target_route, service)[source]¶ Bases:
wasp_general.network.web.proto.WWebPresenterThis is enhanced version of presenter. Besides
WWebPresenterclass. This class objects could use an origin service instance and an origin target route
-
class
wasp_general.network.web.service.WWebPresenterFactory[source]¶ Bases:
wasp_general.network.web.proto.WWebPresenterFactoryProtoWWebPresenterFactoryProto implementation. Can construct classes that do not have their own constructor and are derived from WWebPresenter or from WWebEnhancedPresenter classes
-
static
enhanced_presenter_constructor(presenter_class, request, target_route, service)[source]¶ Function that is used for WWebEnhancedPresenter creating
Parameters: - presenter_class – class to construct
- request – original client request
- target_route – target route to execute
- service – source (parent) service
Returns: WWebEnhancedPresenter
-
instantiable(presenter_class)[source]¶ WWebPresenterFactoryProto.instantiable()method implementation.Checks if class doesn’t have its own constructor and is derived from WWebPresenter or from WWebEnhancedPresenter
Parameters: presenter_class – class to check Returns: bool
-
instantiate(presenter_class, request, target_route, service, *args, **kwargs)[source]¶ WWebPresenterFactoryProto.instantiate()method implementation.Construct new presenter or raise en exception if it isn’t possible.
Parameters: - presenter_class – class to construct
- request – original client request
- target_route – target route to execute
- service – source (parent) service
- args – additional parameters (do not used)
- kwargs – additional parameters (do not used)
Returns: WWebPresenter
-
static
presenter_constructor(presenter_class, request, target_route, service)[source]¶ Function that is used for WWebPresenter creating
Parameters: - presenter_class – class to construct
- request – original client request
- target_route – target route to execute
- service – source (parent) service
Returns: WWebPresenter
-
static
-
class
wasp_general.network.web.service.WWebRoute(pattern, presenter, **kwargs)[source]¶ Bases:
objectClass is used for single route description. It helps to match single request to corresponding presenter (
WWebPresenter). Every route is described by a single pattern (that later compiles to regular expression). Pattern may define different route arguments. There is a way to define default arguments with default values, this is done by passing arguments in object constructor. Every route argument (except special arguments) will be provided to the related presenter action viaWWebTargetRouteclass.Every special argument can be defined in a object constructor, but there is a single special argument (‘action’) that can be defined in pattern also. Special arguments usage: - ‘action’: redefines presenter action. Default value is ‘index’ - ‘virtual_hosts’: is used for request matching. If defined, there must be ‘Host’ header in client request, which equals hostname saved in ‘virtual_hosts’. Hostnames are case-insensitive. Default value is None which is matched to any hostname - ‘protocols’: defines protocol for client request matching. Suitable protocols are ‘http’ or ‘https’. Default value contains both protocols. - ‘ports’: list/tuple/set of ports client is connected to. Default value is None, which is matched to any port - ‘methods’: available client methods like GET, POST, HEAD. Method name is case-sensitive. Default value allow to use GET and POST methods
-
class
ArgSearch[source]¶ Bases:
objectClass for internal usage only. It is used for route argument searching from the given pattern and later pattern preparation
-
class
BasicArgSearch(pattern)[source]¶ Bases:
wasp_general.network.web.service.ArgSearchThis is a simple route argument search, that is looking for simple pattern “{<argument_name>}”. In the prepared patter this argument specification will be replaced with “(w+)” statement
-
arg_re= re.compile('\\{([a-zA-Z][a-zA-Z0-9_]*)\\}')¶ Argument name pattern
-
args()[source]¶ WWebRoute.ArgSearch.args()implementation
-
reduce_pattern()[source]¶ WWebRoute.ArgSearch.reduce_pattern()implementation
-
-
class
CustomArgSearch(arg_name, arg_pos, arg_spec, arg_custom_re_text)[source]¶ Bases:
wasp_general.network.web.service.ArgSearchThis is more complex argument search than
WWebRoute.BasicArgSearch. This class provides an ability to control target argument regular expression. Instead of using simple regexp likeWWebRoute.BasicArgSearchdoes (WWebRoute.BasicArgSearchuses ‘(w+)’), this class will search for a special statements that describe and argument name and corresponding regexp. Statements obey the following format “{<argument_name>:”<regular_expression>”}”.-
args()[source]¶ WWebRoute.ArgSearch.args()implementation
-
classmethod
custom(pattern)[source]¶ Parse the given pattern for arguments and iterate over results (
WWebRoute.CustomArgSearchis yielded)Parameters: pattern – pattern for search Returns: None
-
custom_arg_re= re.compile('(\\{([a-zA-Z][a-zA-Z0-9_]*) *: *"([^"]+)"\\})')¶ Argument name pattern
-
reduce_pattern()[source]¶ WWebRoute.ArgSearch.reduce_pattern()implementation
-
-
match(request, service)[source]¶ Check this route for matching the given request. If this route is matched, then target route is returned.
Parameters: - request – request to match
- service – source service
Returns: WWebTargetRoute or None
-
multiple_slashes_re= re.compile('//+')¶ Regexp for removing extra slashes
-
classmethod
normalize_uri(uri)[source]¶ Normalize the given URI (removes extra slashes)
Parameters: uri – uri to normalize Returns: str
-
pattern_parentheses_removing_nested_re= re.compile('(\\([^()]*\\([^()]*\\)[^()]*\\([^()]*\\)[^()]*\\))')¶ Regexp for removing internal nested parentheses
-
pattern_parentheses_removing_re= re.compile('(\\([^()]*\\([^()]*\\)[^()]*\\))')¶ Regexp for removing internal parentheses
-
pattern_recombination_re= re.compile('(\\([^()]*\\))')¶ Regexp for source argument compilation
-
url_for(**kwargs)[source]¶ Generate url for client with specified route arguments. For the source route ‘/page/{page_index}’ this method must be called with ‘page_index’ parameter (for ‘3’ as ‘page_index’ parameter result will be ‘/page/3’ for ‘foo_bar’ - ‘/page/foo_bar’). If ‘host’, ‘protocol’ and ‘ports’ are set as single element list or they are passed as method parameters, then absolute link is generated as a result.
Every parameter in the source pattern must be defined. They can be defined as this method parameters or in a constructor. If source pattern has more arguments than it can be resolved, then exception will be raised
Parameters: kwargs – route arguments to use Returns: str
-
class
-
class
wasp_general.network.web.service.WWebRouteMap[source]¶ Bases:
wasp_general.network.web.proto.WWebRouteMapProtoThis class represent collection of routes. It has methods for linking a source pattern to th corresponding presenter. There is
WWebRouteMap.route()method that allow to search for a target route by the given client request.WWebRouteMapProtoimplementation-
connect(pattern, presenter, **kwargs)[source]¶ Connect the given pattern with the given presenter
Parameters: - pattern – URI pattern
- presenter – target presenter name
- kwargs – route arguments (see
WWebRoute)
Returns: None
-
error_presenter()[source]¶ WWebRouteMapProto.error_presenter()method implementation
-
import_route(route_as_txt)[source]¶ Import route written as a string
Parameters: route_as_txt – single string (single route) to import Returns: None
-
import_route_arg_re= re.compile('^\\s*([a-zA-Z][a-zA-Z0-9_]*)(\\s*=\\s*(([a-zA-Z0-9_\\-.~%:\\[\\]@!$&\'()*+;="]+)))?\\s*$')¶ Regexp for attribute parsing of imported text
-
import_route_re= re.compile('^\\s*([a-zA-Z0-9_\\-.~%:/?#\\[\\]@!$&\'()*+,;="\\{\\}\\\\]+) +=> +([a-zA-Z][a-zA-Z0-9_.\\-]*)( +\\((.*)\\))?\\s*$')¶ Regexp for text parsing and custom routes importing
-
route(request, service)[source]¶ WWebRouteMapProto.route()method implementation
-
-
class
wasp_general.network.web.service.WWebService(route_map=None, collection=None, factory=None, debugger=None)[source]¶ Bases:
wasp_general.network.web.proto.WWebServiceProtoThis class joins together all web-package functionality.
WWebServiceProtoimplementation-
add_presenter(presenter)[source]¶ Add presenter to a collection. If the given presenter is a
WWebEnhancedPresenterinstance then public routes are checked (viaWWebEnhancedPresenter.__public_routes__()method) and are added in this route mapParameters: presenter – presenter to add Returns: None
-
connect(pattern, presenter, **kwargs)[source]¶ Shortcut for self.route_map().connect() method. It is possible to pass presenter class instead of its name - in that case such class will be saved in presenter collection and it will be available in route matching.
Parameters: - pattern – same as pattern in
WWebRouteMap.connect()method - presenter – presenter name or presenter class
- kwargs – same as kwargs in
WWebRouteMap.connect()method
Returns: None
- pattern – same as pattern in
-
create_presenter(request, target_route)[source]¶ Create presenter from the given requests and target routes
Parameters: - request – client request
- target_route – route to use
Returns: WWebPresenter
-
execute(request, target_route)[source]¶ WWebServiceProto.execute()method implementation
-
presenter_collection()[source]¶ WWebServiceProto.presenter_collection()method implementation
-
presenter_factory()[source]¶ WWebServiceProto.presenter_factory()method implementation
-
process_request(session)[source]¶ Process single request from the given session
Parameters: session – session for reading requests and writing responses Returns: None
-
proxy(request, original_target_route, presenter_name, **kwargs)[source]¶ Execute the given presenter as a target for the given client request
Parameters: - request – original client request
- original_target_route – previous target route
- presenter_name – target presenter name
- kwargs – presenter arguments
Returns: WWebResponseProto
-
route_map()[source]¶ WWebServiceProto.route_map()method implementation
-
-
class
wasp_general.network.web.service.WWebTargetRoute(presenter_name, presenter_action, route, route_map, **presenter_args)[source]¶ Bases:
wasp_general.network.web.proto.WWebTargetRouteProtoSimple
WWebTargetRouteProtoimplementation-
presenter_action()[source]¶ WWebTargetRouteProto.presenter_action()method implementation
-
presenter_args()[source]¶ WWebTargetRouteProto.presenter_args()method implementation
-
wasp_general.network.web.session module¶
-
class
wasp_general.network.web.session.WWebSessionBase(request_cls=<class 'wasp_general.network.web.request.WWebRequest'>)[source]¶ Bases:
wasp_general.network.web.session.WWebSessionAdapterBasic
WWebSessionProtoimplementation. This class clarifies prototype and appends several methods
wasp_general.network.web.template_response module¶
-
class
wasp_general.network.web.template_response.WWebTemplateResponse(template, context=None, status=None, headers=None)[source]¶ Bases:
wasp_general.template.WTemplateRenderer,wasp_general.network.web.response.WWebResponse
wasp_general.network.web.tornado module¶
-
class
wasp_general.network.web.tornado.WTornadoRequestHandler(wasp_web_service, application, request, **kwargs)[source]¶ Bases:
tornado.web.RequestHandlerAccording to http://www.tornadoweb.org/en/stable/web.html, requesthandlers are not thread safe