lektor.context.get_ctx ()

This function returns the currently active Build Context or None if no context is active. This is the main method to access the context. Generally the context is available if a build is active and None if not. This means that if plugins only call that method in places where they know a build is access it's not necessary to check if the context is available.

For more information: Context.


from lektor.context import get_ctx

ctx = get_ctx()