[ZCM] [ZC] 2330/ 2 Edit "ZopeTwoPageTemplateFile should use os.path.normpath"

"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Sun, 12 Aug 2007 05:47:13 -0400
Newsgroups gmane.comp.web.zope.devel.collector-monitor
Message-ID <[email protected]>
Issue #2330 Update (Edit) "ZopeTwoPageTemplateFile should use os.path.normpath"
 Status Pending, Zope/feature+solution medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2330

==============================================================
= Edit - Entry #2 by ajung on Aug 12, 2007 5:47 am

 Changes: submitter email, classification (bug+solution => feature+solution)
________________________________________
= Request - Entry #1 by tuppence on May 30, 2007 9:13 am

I need to be able to use relative paths with `up-level references' (e.g. '../../browser/my_template.pt') for the constructor of Five.browser.pagetemplate.ZopeTwoPageTemplateFile.  On my current system (which is some form of BSD, I believe) this fails in the os.path.isfile call.  Changing the constructor to the following fixes the problem.


    def __init__(self, filename, _prefix=None, content_type=None):
        # XXX doesn't use content_type yet

        self.ZBindings_edit(self._default_bindings)

        path = self.get_path_from_prefix(_prefix)
        filename = os.path.join(path, filename)
        # Resolve any `up-level references' (i.e. '..')
        self.filename = os.path.normpath(filename)
        if not os.path.isfile(self.filename):
            raise ValueError("No such file", self.filename)

==============================================================