Skip to content

[FEATURE REQUEST]: Auto import and register #3

@HamadTheIronside

Description

@HamadTheIronside

Problem

Having this folder structure:

  • Base.py
  • classes
    • child1.py
    • child2.py

At some point, I have to import every single child in some file to register it, and also I have to decorate it. Sometimes it's hard to remember to do this and add the right properties to the children.

Solution suggestion

registery = registerer.Registerer(
    parent_class=BaseClass,
    autoregister=["./classes/*"],
)

This case is suitable for auto-registering. also If I want to unregister, maybe I could add an unregister property to the child class to avoid getting registered automatically.

# classes/child1.py
from base import BaseClass

class Child(BaseClass):
   slug = "child1"
# classes/child2.py
from base import BaseClass

class Child(BaseClass):
   slug = "child1"
   unregister = True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions