Slide 1

Slide 1 text

@easyaspython Using a custom template loader at scale Dane Hillard Lead Web Application Developer 1

Slide 2

Slide 2 text

@easyaspython >>> help(Dane) 2

Slide 3

Slide 3 text

@easyaspython Web: https://dane.dev Twitter: @easyaspython GitHub: @daneah 3

Slide 4

Slide 4 text

@easyaspython 4

Slide 5

Slide 5 text

@easyaspython 5

Slide 6

Slide 6 text

@easyaspython 6

Slide 7

Slide 7 text

@easyaspython 7

Slide 8

Slide 8 text

@easyaspython 8

Slide 9

Slide 9 text

@easyaspython 9

Slide 10

Slide 10 text

@easyaspython 10

Slide 11

Slide 11 text

@easyaspython Enter Django 11

Slide 12

Slide 12 text

@easyaspython 12 Enter Django

Slide 13

Slide 13 text

@easyaspython Django approach ● Distinct Django projects ○ For fault tolerance ○ For independent performance profiling ● A shared core of apps and packages ○ Authentication ○ Permissions ○ Search form ○ Look and feel 13

Slide 14

Slide 14 text

@easyaspython 14 Template approach

Slide 15

Slide 15 text

@easyaspython Changes to look and feel required deployment to every consumer 15

Slide 16

Slide 16 text

@easyaspython This was Not Good® 16

Slide 17

Slide 17 text

@easyaspython Desires ● Consumers receive updates without deployment ● In near-real time ● Without affecting page load performance 17

Slide 18

Slide 18 text

@easyaspython A service for templates? 18

Slide 19

Slide 19 text

@easyaspython ✨ Custom template loader ✨ 19

Slide 20

Slide 20 text

@easyaspython Custom template loader 20 ● What is it? ● How do we use it? ● What did it get us? ● What’s left?

Slide 21

Slide 21 text

@easyaspython What is it? 21

Slide 22

Slide 22 text

@easyaspython 22

Slide 23

Slide 23 text

@easyaspython 23

Slide 24

Slide 24 text

@easyaspython 24

Slide 25

Slide 25 text

@easyaspython django.template.loaders: ● filesystem.Loader ● app_directories.Loader ● cached.Loader 25

Slide 26

Slide 26 text

@easyaspython 26

Slide 27

Slide 27 text

@easyaspython 27

Slide 28

Slide 28 text

@easyaspython How do we use it? 28

Slide 29

Slide 29 text

@easyaspython 29 get_contents get_template_sources

Slide 30

Slide 30 text

@easyaspython 30

Slide 31

Slide 31 text

@easyaspython What did it get us? 31

Slide 32

Slide 32 text

@easyaspython Desires ● ✅ Consumers receive updates without deployment ● ✅ In near-real time ● ✅ Without affecting page load performance 32

Slide 33

Slide 33 text

@easyaspython Per-user configuration for testing changes 33

Slide 34

Slide 34 text

@easyaspython 34

Slide 35

Slide 35 text

@easyaspython 35

Slide 36

Slide 36 text

@easyaspython Demo 36

Slide 37

Slide 37 text

@easyaspython Parallel development of a site-wide redesign 37

Slide 38

Slide 38 text

@easyaspython Problems we faced 38

Slide 39

Slide 39 text

@easyaspython The thundering herd 39

Slide 40

Slide 40 text

@easyaspython cached.Loader configuration 40

Slide 41

Slide 41 text

@easyaspython File management is clumsy 41

Slide 42

Slide 42 text

@easyaspython What’s left? 42

Slide 43

Slide 43 text

@easyaspython Improve adding/removing layouts, cleaning up old templates 43

Slide 44

Slide 44 text

@easyaspython Leverage version control 44

Slide 45

Slide 45 text

@easyaspython render( request, {“conf”: “DjangoCon US”}, “thanks.html”, ) 45