#### This Page

# `lektor.context.``Context`

When Lektor builds sources into finished build artifacts it performs many operations in addition to just creating the end result. For instance it needs to perform dependency tracking, it needs to remember that there might be associated other artifacts and more. All this information is tracked on the `Context` during a build of a single source. At a later point the builder will look at the context to decide on further operations to perform.

The current context can be discovered by calling the get_ctx function which will return it. If there is no artifact build ongoing then the return value will be `None`.

## Basic Example

    from lektor.context import get_ctx

    ctx = get_ctx()
    print('The current source is %s' % ctx.source)

#### changed_base_url()

Can override the base URL that is used for relative URL generation.

#### gather_dependencies()

Can collect dependencies for a code block.

#### locale

The current locale (language/territory) code for the context.

#### pad

A reference to the active database pad.

#### record

A reference to the current source record.

#### record_dependency()

Instructs the builder to record a new dependency for the current artifact.

#### source

A reference to the current source object.

#### sub_artifact()

Creates a sub-artifact of the current one.

## Comments