Skip to content

How does it work?

Corentin Bettiol edited this page Nov 18, 2019 · 9 revisions

The checks system used in this django module is not something you usually see in Python projects.

image

I'm lost! Why are there so many files?

The main reason to the unusual organization of this module is to provide a simple & clean interface to create your own checks.


What is the meaning of all those files ?

Each file is a check (or a group of checks on the same parameter), except launch_checks.py & __init__.py.


What is the file launch_checks.py for ?

Since a03d6599, its purpose is to execute run & important functions on submodules located in django-check-seo.checks.* and in project folder (it looks for the /path/to/your/project/checks/ folder (if it exists), and add its modules).


What is the file __init__.py for ?

It lists the files inside the /path/to/site-package/django-check-seo/checks/ folder, then it adds the modules to the __all__ var (it's the var that makes modules available in the from . import * in launch_checks.py)


What are the functions inside checks files?

importance()

This is the function that tells launch_checks if the current check must be performed before the others, or if it doesn't matter.

Its only purpose is to return an int (the recommended use is between 1 and 5).

The higher the number, the faster the function will be executed.

Since check_keywords populates the site.keywords var, it need to be executed before all the functions that will use site.keywords var.

run()

This is the main function of your file, the one that will do the check and that will populate the site.warnings and/or site.problems lists.


What are the problems & warnings dict?

coming soon (the code will soon change, I don't want to write something obsolete)


How do I add a check?

See How to add a check?.


Content

If you want to know the reasons why we chose these checks in particular.

Checks that are not included inside the project


Code

Clone this wiki locally