ZopeTwoPageTemplateFile should use os.path.normpath

Bug #143923 reported by Tim Hicks on 2007-05-30
Affects Status Importance Assigned to Milestone

Bug Description

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


        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)

Andreas Jung (ajung) wrote :

Changes: submitter email, classification (bug+solution => feature+solution)

The code in question (the self.filename assignment) is now in zope.pagetemplate.pagetemplatefile.PageTemplateFile.__init__

affects: zope2 → zope.pagetemplate
Colin Watson (cjwatson) wrote :

The zope.pagetemplate project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.pagetemplate.

Changed in zope.pagetemplate:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers