pigeon.core.app

Module Contents

class pigeon.core.app.Manager

Used to manage settings and load specified middleware which is only loaded at runtime.

To override settings either the method Manager.override or the Manager.__get_attr__ method is used:

# override settings using a module or similar behaving object
my_settings: types.ModuleType = ...
Manager.override(my_settings)

# override settings one at a time by accessing the attributes (__getattr__)
Manager.my_setting = my_value
classmethod override(new_settings: types.ModuleType | Any)

Overrides current settings with new settings provided.

Parameters:

new_settings – New settings to override old ones with

pigeon.core.app.log
class pigeon.core.app.Pigeon(settings=None)

The Pigeon class is the main interface used for the user to interact with Pigeon. It houses important decorators for registering views, etc. such as Pigeon.view and Pigeon.error.

Furthermore it facilitates exception-handling, exit-handling, debug_mode application reinitialization through watchdog,

settings = None
autorun = True
observers = []
classmethod run(auto=False) None
Parameters:

auto – specifies whether the application has been started automatically due to the atexit call,

if so we will check back whether this

classmethod restart()

Restarts the entire application

classmethod handle_exception(exception_type, exception, *args, custom_log: pigeon.utils.logger.Log = log, description: str = 'AN EXCEPTION OCCURED') None
Parameters:
  • exception_type – Type of exception (unused)

  • exception – The exception that should be handled

  • custom_log – Pigeon log that error message corresponding to the exception will be logged in

  • description – The status message that will be logged to explain or give details about the error

This is a custom exception handler. It facilitates the following:

  • if an exception occurs before the server has started, the server will not start

  • exceptions during runtime will be logged and if the CRASH_ON_FAILURE setting is set to True the app will terminate

classmethod handle_exit(status, force: bool = False) None
classmethod view(target: str, mimetype: str = '*/*', auth=None) Callable
classmethod error(code: int) Callable