(self, alias)
| 65 | return templates |
| 66 | |
| 67 | def __getitem__(self, alias): |
| 68 | try: |
| 69 | return self._engines[alias] |
| 70 | except KeyError: |
| 71 | try: |
| 72 | params = self.templates[alias] |
| 73 | except KeyError: |
| 74 | raise InvalidTemplateEngineError( |
| 75 | "Could not find config for '{}' " |
| 76 | "in settings.TEMPLATES".format(alias) |
| 77 | ) |
| 78 | |
| 79 | # If importing or initializing the backend raises an exception, |
| 80 | # self._engines[alias] isn't set and this code may get executed |
| 81 | # again, so we must preserve the original params. See #24265. |
| 82 | params = params.copy() |
| 83 | backend = params.pop("BACKEND") |
| 84 | engine_cls = import_string(backend) |
| 85 | engine = engine_cls(params) |
| 86 | |
| 87 | self._engines[alias] = engine |
| 88 | return engine |
| 89 | |
| 90 | def __iter__(self): |
| 91 | return iter(self.templates) |
nothing calls this directly
no test coverage detected