| |
- WebScripts.utils.DefaultNamespace(types.SimpleNamespace)
-
- WebScripts.WebScripts.Configuration
- builtins.object
-
- WebScripts.WebScripts.Server
class Configuration(WebScripts.utils.DefaultNamespace) |
|
Configuration(required: List[str] = [], optional: List[str] = [], default: dict = {}, types: dict = {})
This class build the configuration from dict(s) with
configuration files and arguments. |
|
- Method resolution order:
- Configuration
- WebScripts.utils.DefaultNamespace
- types.SimpleNamespace
- builtins.object
Methods defined here:
- add_conf(self, **kwargs)
- Add configurations from other configuration files found.
Data and other attributes defined here:
- __defaults__ = {'accept_unauthenticated_user': True, 'accept_unknow_user': True, 'active_auth': False, 'auth_script': None, 'documentations_path': [], 'interface': '127.0.0.1', 'js_path': [], 'log_level': 0, 'modules': [], 'modules_path': [], ...}
- __optional__ = ('debug', 'security', 'active_auth', 'auth_script', 'accept_unknow_user', 'accept_unauthenticated_user', 'modules', 'modules_path', 'js_path', 'statics_path', 'documentations_path', 'scripts_path', 'json_scripts_config', 'ini_scripts_configlog_level', 'log_filename', 'log_level', 'log_format', 'log_date_format', 'log_encoding', 'auth_failures_to_blacklist', ...)
- __required__ = ('interface', 'port')
- __types__ = {'accept_unauthenticated_user': <class 'bool'>, 'accept_unknow_user': <class 'bool'>, 'active_auth': <class 'bool'>, 'admin_adresses': <class 'list'>, 'auth_failures_to_blacklist': <class 'int'>, 'blacklist_time': <class 'int'>, 'debug': <class 'bool'>, 'documentations_path': <class 'list'>, 'ini_scripts_config': <class 'list'>, 'js_path': <class 'list'>, ...}
Methods inherited from WebScripts.utils.DefaultNamespace:
- __getitem__(self, key: str)
- Compatibility with dict.
- __init__(self, required: List[str] = [], optional: List[str] = [], default: dict = {}, types: dict = {})
- Initialize self. See help(type(self)) for accurate signature.
- build_types(self) -> None
- This function build type from configuration values.
- check_required(self) -> None
- This function checks required attributes
if one of required attributes is missing this
function raise MissingAttributesError.
- export_as_json(self, name: str = None) -> None
- This function export namespace values (useful for debugging).
- get(self, key: str, default=None)
- Compatibility with dict.
- get_dict(self) -> None
- This function return a dict of attributes.
- get_missings(self) -> List[str]
- This function checks required attributes
and return a List[str] of missing required attributes.
- get_unexpecteds(self, log: bool = True) -> List[str]
- This function return a List[str] of
all attributes not in optional and
required attributes.
If log argument is True a Warning log message is
write for all unexpected attributes.
- set_defaults(self) -> None
- This function set defaults attribut with defaults values.
- update(self, **kwargs)
- This function add/update attributes with **kwargs arguments.
Class methods inherited from WebScripts.utils.DefaultNamespace:
- default_build(**kwargs) -> ~DefaultNamespace from builtins.type
- Default build for DefaultNamespace (set defaults, add values, check
requirements and unexpected values and build types).
Data descriptors inherited from WebScripts.utils.DefaultNamespace:
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from types.SimpleNamespace:
- __delattr__(self, name, /)
- Implement delattr(self, name).
- __eq__(self, value, /)
- Return self==value.
- __ge__(self, value, /)
- Return self>=value.
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __gt__(self, value, /)
- Return self>value.
- __le__(self, value, /)
- Return self<=value.
- __lt__(self, value, /)
- Return self<value.
- __ne__(self, value, /)
- Return self!=value.
- __reduce__(...)
- Return state information for pickling
- __repr__(self, /)
- Return repr(self).
- __setattr__(self, name, value, /)
- Implement setattr(self, name, value).
Static methods inherited from types.SimpleNamespace:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors inherited from types.SimpleNamespace:
- __dict__
Data and other attributes inherited from types.SimpleNamespace:
- __hash__ = None
|
class Server(builtins.object) |
|
Server(configuration: WebScripts.WebScripts.Configuration)
This class implement the WebScripts server. |
|
Methods defined here:
- __init__(self, configuration: WebScripts.WebScripts.Configuration)
- Initialize self. See help(type(self)) for accurate signature.
- add_module_or_package(self) -> None
- This function add packages and modules to build custom page.
- add_paths(self) -> None
- This function add js, static and scripts paths.
- app(self, environ: os._Environ, respond: function) -> List[bytes]
- This function get function page,
return content page, catch errors and
return HTTP errors.
- check_auth(self, environ: os._Environ) -> Tuple[WebScripts.commons.User, bool]
- This function check if user is authenticated and blacklisted.
- check_blacklist(self, user: WebScripts.commons.User, ip: str) -> bool
- This function checks that the IP and the
username are not in the blacklist.
- get_URLs(self) -> List[str]
- This function return a list of string.
- get_attributes(self, object_: object, attributes: List[str]) -> Tuple[~FunctionOrNone, str]
- This function get recursive attribute from object.
- get_function_page(self, path: str) -> ~FunctionOrNone
- This function find function from URL path.
- get_inputs(self, arguments: List[Dict[str, ~JsonValue]]) -> Tuple[List[str], Dict[str, ~JsonValue]]
- This function returns inputs and arguments from arguments.
- get_session(self, cookies: List[str], ip: str) -> WebScripts.commons.User
- This function return User from cookies.
- page_401(self, error_description: str, respond: function)
- This function return error 401 web page.
- page_403(self, error_description: str, respond: function)
- This function return error 403 web page.
- page_404(self, url: str, respond: function)
- This function return error 404 web page.
- page_500(self, error: str, respond: function) -> List[bytes]
- This function return error 500 web page.
- parse_body(self, environ: os._Environ) -> Tuple[List[Dict[str, ~JsonValue]], str]
- This function return arguments from body.
- send_custom_error(self, error: str, code: str) -> Tuple[str, Dict[str, str], str]
- This function call custom errors pages.
- send_error_page(self, error: str, data: bytes, respond: function) -> List[bytes]
- This function send HTTP errors.
- send_headers(self, respond: function, error: str = None, headers: Dict[str, str] = None) -> None
- This function send error code, message and headers.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |