Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: inline: make the album/item available directly #5439

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 26, 2024

  1. inline: make the album/item available directly

    There have been multiple requests, in the past, for the ability to use
    plugin fields in inline fields. This has not previously been available.
    From what I can tell, it was intentionally left unavailable due to
    performance concerns.
    
    The way the item fields are made available to the inline python code
    means that all fields are looked up, whether they're actually used by
    the code or not. Doing that for all computed fields would be a
    performance concern.
    
    I don't believe there's a good way to postpone the field computation, as
    python eval and compile requires that globals be a dictionary, not a
    mapping. Instead, we can make available the album or item model object
    to the code directly, and let the code access the fields it needs via
    that object, resulting in postponing the computation of the fields until
    they're actually accessed.
    
    This is a simple approach that makes the computed and plugin fields
    available to inline python, which allows for more code reuse, as well as
    more options for shifting logic out of templates and into python code.
    
    In items, the object is available as 'item', and in albums, it's
    available as 'album'.
    
    Examples:
    
        item_fields:
          test_file_size: item.filesize
    
        album_fields:
          test_album_path: album.path
          # If the missing plugin is enabled
          test_album_missing: album.missing
    
    Signed-off-by: Christopher Larson <[email protected]>
    kergoth committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    8692b30 View commit details
    Browse the repository at this point in the history