joop.web.view — joop 0.0.1 documentation

# joop.web.view

Views are how components are integrated with webservers. The view (or route) is defined

  and established by this class.

Classes:
  View:

    The base class for defining and managing views in the joop project.

Classes

`View`() | The base class for defining and managing views in the joop project.

class joop.web.view.View

  Bases: `object`

  The base class for defining and managing views in the joop project.

  This class provides methods for rendering components, managing inputs and subcomponents, and integrating views with web frameworks.

  _component_type

    The type of the component associated with the view.

    Type:

      Type[Component]

  _args_to_inputs

    Determines whether to automatically map arguments to component inputs.

    Type:

      bool

  _get_default_subs

    Determines whether to automatically retrieve default subcomponents.

    Type:

      bool

  _as_response

    Determines whether the view should render a response instead of a component.

    Type:

      bool

  _get_inputs(**kwargs)

    Retrieves the inputs for the component based on the provided keyword arguments.

  _get_subs(**kwargs)

    Retrieves the default subcomponents for the component.

  render(**kwargs)

    Renders the component and returns the rendered output as a string.

  _add_to_app(app

    object, view_func: Callable): Abstract method to add the view to a web application.

  add_to_app(app

    object): Adds the view to a web application with the specified configuration.

  _get_jinja_env()

    Abstract method to retrieve the Jinja2 environment.

  get_jinja_env()

    Retrieves the Jinja2 environment by calling the abstract method.

  class Endpoint

    Bases: `object`

  classmethod add_to_app(app: object)

    Add the view to a web application with the specified configuration.

    This method validates the view’s configuration and registers it with the web application using the _add_to_app method.

    Parameters:

      app (object) – The web application instance.

    Raises:

      NotImplementedError – If the view’s configuration is incomplete or invalid.

  classmethod get_jinja_env()

    Retrieve the Jinja2 environment by calling the abstract method.

    Returns:

      The Jinja2 environment associated with the view.

    Return type:

      jinja2.Environment

  classmethod render(**kwargs)

    Render the component and return the rendered output as a string.

    Parameters:

      **kwargs – Keyword arguments to be passed to the component’s inputs and subcomponents.

    Returns:

      The rendered output of the component.

    Return type:

      str