[Zope-Checkins] SVN: Zope/trunk/ Changed PageTemplateFile not to
load the file contents on Zope startup anymore but on first
access instead. This brings them inline with the
zope.pagetemplate version and speeds up Zope startup.
Hanno Schlichting
plone at hannosch.info
Sat Oct 20 05:58:00 EDT 2007
Log message for revision 80940:
Changed PageTemplateFile not to load the file contents on Zope startup anymore but on first access instead. This brings them inline with the zope.pagetemplate version and speeds up Zope startup.
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/lib/python/Products/PageTemplates/PageTemplateFile.py
U Zope/trunk/lib/python/Products/PageTemplates/tests/test_ptfile.py
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2007-10-19 16:05:16 UTC (rev 80939)
+++ Zope/trunk/doc/CHANGES.txt 2007-10-20 09:57:58 UTC (rev 80940)
@@ -71,10 +71,6 @@
Features added
- - Added LAZY_FILE_LOADING constant to PageTemplateFile. When set to True
- Page Template files aren't lo aded and parsed on Zope startup anymore,
- but on first access instead.
-
- Testing.ZopeTestCase: Introduced a "ZopeLite" test layer, making it
possible to mix ZTC and non-ZTC tests much more freely.
@@ -179,6 +175,10 @@
Bugs Fixed
+ - Changed PageTemplateFile not to load the file contents on Zope startup
+ anymore but on first access instead. This brings them inline with the
+ zope.pagetemplate version and speeds up Zope startup.
+
- Launchpad #147201: treat container-class in zope.conf as a string,
making it possible to use types from extra products directories.
Modified: Zope/trunk/lib/python/Products/PageTemplates/PageTemplateFile.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/PageTemplateFile.py 2007-10-19 16:05:16 UTC (rev 80939)
+++ Zope/trunk/lib/python/Products/PageTemplates/PageTemplateFile.py 2007-10-20 09:57:58 UTC (rev 80940)
@@ -31,8 +31,6 @@
LOG = getLogger('PageTemplateFile')
-LAZY_FILE_LOADING = False
-
def guess_type(filename, text):
# check for XML ourself since guess_content_type can't
@@ -88,10 +86,6 @@
self.filename = filename
- if not LAZY_FILE_LOADING:
- content = open(filename).read()
- self.pt_edit( content, guess_type(filename, content))
-
def pt_getContext(self):
root = self.getPhysicalRoot()
context = self._getContext()
Modified: Zope/trunk/lib/python/Products/PageTemplates/tests/test_ptfile.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/tests/test_ptfile.py 2007-10-19 16:05:16 UTC (rev 80939)
+++ Zope/trunk/lib/python/Products/PageTemplates/tests/test_ptfile.py 2007-10-20 09:57:58 UTC (rev 80940)
@@ -8,7 +8,6 @@
from Testing.makerequest import makerequest
-from Products.PageTemplates import PageTemplateFile as PTF
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
@@ -197,29 +196,15 @@
class LazyLoadingTestCase(unittest.TestCase):
TEMPFILENAME = tempfile.mktemp(".zpt")
- OLD_LAZY = None
- def setUp(self):
- self.OLD_LAZY = PTF.LAZY_FILE_LOADING
-
def tearDown(self):
if os.path.exists(self.TEMPFILENAME):
os.unlink(self.TEMPFILENAME)
- PTF.LAZY_FILE_LOADING = self.OLD_LAZY
- def test_not_lazy(self):
- f = open(self.TEMPFILENAME, 'w')
- print >> f, 'Lazyness'
- f.close()
- pt = PageTemplateFile(self.TEMPFILENAME)
- self.failUnless(pt._text.startswith('Lazyness'))
- self.failUnless(pt._v_program)
-
def test_lazy(self):
f = open(self.TEMPFILENAME, 'w')
print >> f, 'Lazyness'
f.close()
- PTF.LAZY_FILE_LOADING = True
pt = PageTemplateFile(self.TEMPFILENAME)
self.failUnless(not pt._text and not pt._v_program)
More information about the Zope-Checkins
mailing list