Thread Safety with Template Tags
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Question
03:27 Accepted answer (Score 1)
04:14 Thank you
--
Full question
https://stackoverflow.com/questions/7483...
Question links:
[this document]: https://docs.djangoproject.com/en/dev/ho...
[here]: https://docs.djangoproject.com/en/dev/ho.../
Accepted answer links:
[this]: https://docs.djangoproject.com/en/dev/ho.../
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #concurrency #djangotemplates
#avk47
    --
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Question
03:27 Accepted answer (Score 1)
04:14 Thank you
--
Full question
https://stackoverflow.com/questions/7483...
Question links:
[this document]: https://docs.djangoproject.com/en/dev/ho...
[here]: https://docs.djangoproject.com/en/dev/ho.../
Accepted answer links:
[this]: https://docs.djangoproject.com/en/dev/ho.../
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #concurrency #djangotemplates
#avk47
ACCEPTED ANSWER
Score 1
Got it with closer reading of this.
The template is compiled when it is loaded. Any arguments passed into the tag function are 'static'. They are either literal strings, or they are strings which are used as identifiers to look up bound variables in the render context.
Therefore the Node object is instantiated for each tag, and hangs around ready for use whenever the template is used (and naturally the template may be used in any number of threads).
Thus the self in my question is the identity of the specific Node within the template. Combined with the render context, this gives a unique identity on which to hang instance variables.