fava.ext¶
Fava’s extension system.
- exception fava.ext.ExtensionConfigError(error, config)¶
- class fava.ext.FavaExtensionBase(ledger, config=None)¶
Base class for extensions for Fava.
Any extension should inherit from this class.
find_extension()
will discover all subclasses of this class in the specified modules.- after_insert_metadata(entry, key, value)¶
Run after metadata (key: value) was added to an entry.
- Return type:
- property jinja_env: Environment¶
Jinja env for this extension.
- class fava.ext.FavaExtensionError(source: Meta | None, message: str, entry: Directive | None)¶
Error in one of Fava’s extensions.
- exception fava.ext.JinjaLoaderMissingError¶
- fava.ext.extension_endpoint(func_or_endpoint_name=None, methods=None)¶
Decorator to mark a function as an endpoint.
Can be used as @extension_endpoint or @extension_endpoint(endpoint_name, methods).
When used as @extension_endpoint, the endpoint name is the name of the function and methods is “GET”.
When used as @extension_endpoint(endpoint_name, methods), the given endpoint name and methods are used, but both are optional. If endpoint_name is None, default to the function name, and if methods is None, default to “GET”.
- Return type:
Union
[Callable
[[TypeVar
(T
, bound=FavaExtensionBase
)],Response
],Callable
[[Callable
[[TypeVar
(T
, bound=FavaExtensionBase
)],Response
]],Callable
[[TypeVar
(T
, bound=FavaExtensionBase
)],Response
]]]
- fava.ext.find_extensions(base_path, name)¶
Find extensions in a module.
- Parameters:
- Returns:
tuple
[list
[type
[FavaExtensionBase
]],list
[FavaExtensionError
]] – A tuple (classes, errors) where classes is a list of subclasses ofFavaExtensionBase
found inname
.
fava.ext.auto_commit¶
Auto-commit hook for Fava.
This mainly serves as an example how Fava’s extension systems, which only really does hooks at the moment, works.