The writers.preptool.slugify_name() helper kept a set of seen_slugs as a module-level variable. As a result, uniqueness among slugs was enforced for the entire lifetime of a module import, including across PrepToolWriter instances and across multiple calls to prep().
In xml2rfc itself, this appears to have been adding unnecessary "-2" suffixes on many HTML ids, at least in the tests. For datatracker's use of xml2rfc as a library, this was causing difficulties with long-lived celery workers by adding suffixes to prevent collisions between entirely separate drafts and eventually running out of unique slugs.
This makes the slugify_name() procedure a method on PrepToolWriter and resets the seen_slugs cache, now a property of the instance, on each invocation of prep()
The
writers.preptool.slugify_name()
helper kept a set ofseen_slugs
as a module-level variable. As a result, uniqueness among slugs was enforced for the entire lifetime of a module import, including acrossPrepToolWriter
instances and across multiple calls toprep()
.In xml2rfc itself, this appears to have been adding unnecessary "-2" suffixes on many HTML ids, at least in the tests. For datatracker's use of xml2rfc as a library, this was causing difficulties with long-lived celery workers by adding suffixes to prevent collisions between entirely separate drafts and eventually running out of unique slugs.
This makes the
slugify_name()
procedure a method onPrepToolWriter
and resets theseen_slugs
cache, now a property of the instance, on each invocation ofprep()