Skip to content

Restructure source tree

Julian requested to merge restructure into master

Move all models, views, cli commands and templates into corresponding top-level folders. Detailed changes:

  • uffd/<NAME>/models.py -> uffd/models/<NAME>.py
  • uffd/<NAME>/cli.py -> uffd/commands/<NAME>.py
  • uffd/<NAME>/views.py -> uffd/views/<NAME>.py
  • uffd/<NAME>/templates/* -> uffd/templates/
  • uffd/ratelimit.py -> uffd/models/ratelimit.py (it contains models)
  • gendevcert from uffd/__init__.py -> uffd/commands/gendevcert.py
  • profile from uffd/__init__.py -> uffd/commands/profile.py
  • cleanup from uffd/tasks.py -> uffd/commands/cleanup.py
  • roles-update-all from uffd/role/views.py -> uffd/commands/...
  • Views from uffd/__init__.py -> uffd/views/__init__.py
  • All models can/should be imported from uffd.models
  • flask shell auto-imports all models instead of only a few

The old structure was meant to keep the code modular and related code/resources close to each other. However, the modules turned out to be heavily interdependent and not very modular. Also importing was fragile due to ordering issues.

With the new structure the dependency tree is much simpler: Infrastructure code (top-level *.py files) has no internal dependencies. Models only depend on infrastructure and other models. Views and cli commands depend on infrastructure, models and other views/commands.

Going forward there is still some restructuring to do, e.g.:

  • Move mfa setup views to selfservice views
  • Move mfa auth views to session views
  • Move utility code from views to infrastructure (e.g. login_required)
  • In most cases views should not need to import from other views
  • Reorganize infrastructure code
Edited by Julian

Merge request reports