ZopeTwoPageTemplateFile should use os.path.normpath

Reported by Tim Hicks on 2007-05-30
2
Affects Status Importance Assigned to Milestone
zope.pagetemplate
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)

Andreas Jung (ajung) wrote :

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

Jens Vagelpohl (dataflake) wrote :

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

affects: zope2 → zope.pagetemplate
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers