Edgewall Software

Ticket #367: base.py.patch

File base.py.patch, 2.8 KB (added by db3l.net@…, 13 years ago)

Absolute template reference patch

Line 
1*** base.py     2008-07-09 19:36:08.000000000 -0400
2--- base.py.absolute    2010-11-29 16:51:39.000000000 -0500
3***************
4*** 439,446 ****
5                          # If the path to the included template is static, and
6                          # auto-reloading is disabled on the template loader,
7                          # the template is inlined into the stream
8                          try:
9!                             tmpl = self.loader.load(href, relative_to=pos[0],
10                                                      cls=cls or self.__class__)
11                              for event in tmpl.stream:
12                                  yield event
13--- 439,456 ----
14                          # If the path to the included template is static, and
15                          # auto-reloading is disabled on the template loader,
16                          # the template is inlined into the stream
17+
18+                         # Absolute references are relative to search path,
19+                         # not parent file
20+                         if href[0] == '/':
21+                             href = href[1:]
22+                             relative_to = None
23+                         else:
24+                             relative_to = pos[0]
25+
26                          try:
27!                             tmpl = self.loader.load(href,
28!                                                     relative_to=relative_to,
29                                                      cls=cls or self.__class__)
30                              for event in tmpl.stream:
31                                  yield event
32***************
33*** 576,583 ****
34                          if subkind is TEXT:
35                              parts.append(subdata)
36                      href = u''.join([x for x in parts if x is not None])
37                  try:
38!                     tmpl = self.loader.load(href, relative_to=event[2][0],
39                                              cls=cls or self.__class__)
40                      for event in tmpl.generate(ctxt, **vars):
41                          yield event
42--- 586,603 ----
43                          if subkind is TEXT:
44                              parts.append(subdata)
45                      href = u''.join([x for x in parts if x is not None])
46+                 #
47+                 # Absolute references are relative to search path,
48+                 # not parent file
49+                 #
50+                 if href[0] == '/':
51+                     href = href[1:]
52+                     relative_to = None
53+                 else:
54+                     relative_to = event[2][0]
55+
56                  try:
57!                     tmpl = self.loader.load(href, relative_to=relative_to,
58                                              cls=cls or self.__class__)
59                      for event in tmpl.generate(ctxt, **vars):
60                          yield event