Edgewall Software

Changeset 371


Ignore:
Timestamp:
Oct 16, 2006, 10:11:47 AM (17 years ago)
Author:
cmlenz
Message:

Ported [370] to 0.3.x branch.

Location:
branches/stable/0.3.x/genshi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/0.3.x/genshi/template.py

    r366 r371  
    13411341
    13421342        search_path = self.search_path
     1343        isabs = False
    13431344
    13441345        if os.path.isabs(filename):
    13451346            # Bypass the search path if the requested filename is absolute
    13461347            search_path = [os.path.dirname(filename)]
     1348            isabs = True
    13471349
    13481350        elif relative_to and os.path.isabs(relative_to):
     
    13511353            dirname = os.path.dirname(relative_to)
    13521354            if dirname not in search_path:
    1353                 search_path = search_path[:] + [dirname]
     1355                search_path = search_path + [dirname]
     1356            isabs = True
    13541357
    13551358        elif not search_path:
     
    13621365                fileobj = open(filepath, 'U')
    13631366                try:
     1367                    if isabs:
     1368                        # If the filename of either the included or the
     1369                        # including template is absolute, make sure the
     1370                        # included template gets an absolute path, too,
     1371                        # so that nested include work properly without a
     1372                        # search path
     1373                        filename = os.path.join(dirname, filename)
     1374                        dirname = ''
    13641375                    tmpl = cls(fileobj, basedir=dirname, filename=filename,
    13651376                               loader=self)
  • branches/stable/0.3.x/genshi/tests/template.py

    r357 r371  
    11751175            </html>""", tmpl.generate().render())
    11761176
     1177    def test_relative_include_without_search_path_nested(self):
     1178        file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w')
     1179        try:
     1180            file1.write("""<div>Included</div>""")
     1181        finally:
     1182            file1.close()
     1183
     1184        file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w')
     1185        try:
     1186            file2.write("""<div xmlns:xi="http://www.w3.org/2001/XInclude">
     1187              <xi:include href="tmpl1.html" />
     1188            </div>""")
     1189        finally:
     1190            file2.close()
     1191
     1192        file3 = open(os.path.join(self.dirname, 'tmpl3.html'), 'w')
     1193        try:
     1194            file3.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude">
     1195              <xi:include href="tmpl2.html" />
     1196            </html>""")
     1197        finally:
     1198            file3.close()
     1199
     1200        loader = TemplateLoader()
     1201        tmpl = loader.load(os.path.join(self.dirname, 'tmpl3.html'))
     1202        self.assertEqual("""<html>
     1203              <div>
     1204              <div>Included</div>
     1205            </div>
     1206            </html>""", tmpl.generate().render())
     1207
    11771208    def test_relative_include_from_inmemory_template(self):
    11781209        file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w')
Note: See TracChangeset for help on using the changeset viewer.