Commit 7cdaddf3 authored by Fred Drake's avatar Fred Drake

- clean up some filename manipulation to avoid duplicate work and make

  it more readable
- remove unused instance variable
parent 5cc7ab63
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template from the filesystem. Zope object encapsulating a Page Template from the filesystem.
""" """
__version__='$Revision: 1.26 $'[11:-2] __version__='$Revision: 1.27 $'[11:-2]
import os, AccessControl import os, AccessControl
from Globals import package_home, DevelopmentMode from Globals import package_home, DevelopmentMode
...@@ -37,7 +37,6 @@ class PageTemplateFile(Script, PageTemplate, Traversable): ...@@ -37,7 +37,6 @@ class PageTemplateFile(Script, PageTemplate, Traversable):
func_defaults = None func_defaults = None
func_code = FuncCode((), 0) func_code = FuncCode((), 0)
_need__name__=1
_v_last_read=0 _v_last_read=0
_default_bindings = {'name_subpath': 'traverse_subpath'} _default_bindings = {'name_subpath': 'traverse_subpath'}
...@@ -53,12 +52,14 @@ class PageTemplateFile(Script, PageTemplate, Traversable): ...@@ -53,12 +52,14 @@ class PageTemplateFile(Script, PageTemplate, Traversable):
elif not isinstance(_prefix, str): elif not isinstance(_prefix, str):
_prefix = package_home(_prefix) _prefix = package_home(_prefix)
name = kw.get('__name__') name = kw.get('__name__')
basepath, ext = os.path.splitext(filename)
if name: if name:
self._need__name__ = 0
self.__name__ = name self.__name__ = name
else: else:
self.__name__ = os.path.splitext(os.path.split(filename)[-1])[0] self.__name__ = os.path.basename(basepath)
if not os.path.splitext(filename)[1]: if not ext:
# XXX This is pretty bogus, but can't be removed since
# it's been released this way.
filename = filename + '.zpt' filename = filename + '.zpt'
self.filename = os.path.join(_prefix, filename) self.filename = os.path.join(_prefix, filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment