Do some heavy clean up in ZopePageTemplate which gets rid of a lot of temporary

hacks that were in there before.  Tried to reduce the diff to the Zope 2.9 code
a little and moved some content type guessing code to PageTemplateFile where it
really belongs (that also avoids a circular import problem).
parent 5990331e
......@@ -25,12 +25,18 @@ from Shared.DC.Scripts.Script import Script
from Shared.DC.Scripts.Signature import FuncCode
from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.PageTemplates.PageTemplate import PageTemplate
from Products.PageTemplates.ZopePageTemplate import guess_type
from zope.contenttype import guess_content_type
from zope.pagetemplate.pagetemplatefile import sniff_type
LOG = getLogger('PageTemplateFile')
def guess_type(filename, text):
content_type, dummy = guess_content_type(filename, text)
if content_type in ('text/html', 'text/xml'):
return content_type
return sniff_type(text) or 'text/html'
class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
"""Zope 2 implementation of a PageTemplate loaded from a file."""
......
......@@ -12,7 +12,6 @@ import Zope2
import transaction
from Testing.makerequest import makerequest
from Products.PageTemplates.ZopePageTemplate import _default_content_fn
class ZPTRegressions(unittest.TestCase):
......@@ -35,7 +34,7 @@ class ZPTRegressions(unittest.TestCase):
def testAddWithoutParams(self):
pt = self._addPT('pt1')
default_text = open(_default_content_fn).read()
default_text = open(pt._default_content_fn).read()
self.assertEqual(pt.title, '')
self.assertEqual(pt.document_src().strip(), default_text.strip())
......
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