Skip to content

Cleanup old "old_plugins" import code #11758

@RayBB

Description

@RayBB

Problem

@cdrini mentioned here that this code is very challenging to read and a bit too magical we should simplify it if we can, especially as we have to keep digging deeper into web.py for the fastapi migration.

old_plugins = [
"openlibrary",
"worksearch",
"inside",
"books",
"admin",
"upstream",
"importapi",
]
def setup():
setup_logging()
logger = logging.getLogger("openlibrary")
logger.info("Application init")
for p in old_plugins:
logger.info("loading plugin %s", p)
modname = f"openlibrary.plugins.{p}.code"
path = "openlibrary/plugins/" + p
template.load_templates(path, lazy=True)
macro.load_macros(path, lazy=True)
i18n.load_strings(path)
__import__(modname, globals(), locals(), ['plugins'])
delegate.plugins += [
delegate._make_plugin_module('openlibrary.plugins.' + name)
for name in old_plugins
]

Reproducing the bug

It's not a bug...

Context

.

Breakdown

Requirements Checklist

  • [ ]

Related files

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

Metadata

Metadata

Assignees

Labels

Needs: BreakdownThis big issue needs a checklist or subissues to describe a breakdown of work. [managed]Needs: LeadNeeds: TriageThis issue needs triage. The team needs to decide who should own it, what to do, by when. [managed]Type: BugSomething isn't working. [managed]

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions