ZopeTwoPageTemplateFile should use os.path.normpath

Bug #143923 reported by Tim Hicks
2
Affects Status Importance Assigned to Milestone
zope.pagetemplate
Invalid
Medium
Unassigned

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

        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)

Revision history for this message
Andreas Jung (ajung) wrote :

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

Revision history for this message
Jens Vagelpohl (dataflake-deactivatedaccount-deactivatedaccount) wrote :

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

affects: zope2 → zope.pagetemplate
Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.