Changeset 1473 in products
- Timestamp:
- Dec 25, 2009 2:02:06 PM (14 years ago)
- Location:
- quintagroup.pagetemplateshrink/trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.pagetemplateshrink/trunk/quintagroup/pagetemplateshrink/__init__.py
r1472 r1473 1 1 # 2 from zope.pagetemplate import pagetemplate 3 4 import re 5 expression = re.compile('[ \n\f\r]+(?=</?(?:me)?tal)') 6 expression2 = re.compile('\n\s*\n+(?= *<)') 7 8 def cook(self): 9 """Compile the TAL and METAL statments. 10 11 Cooking must not fail due to compilation errors in templates. 12 """ 13 engine = self.pt_getEngine() 14 source_file = self.pt_source_file() 15 if self.content_type == 'text/html': 16 gen = TALGenerator(engine, xml=0, source_file=source_file) 17 parser = HTMLTALParser(gen) 18 else: 19 gen = TALGenerator(engine, source_file=source_file) 20 parser = TALParser(gen) 21 22 self._v_errors = () 23 try: 24 #### the patch 25 text = self._text 26 text = expression.sub('', text) 27 text = expression2.sub('', text) 28 parser.parseString(text) 29 #parser.parseString(self._text) 30 self._v_program, self._v_macros = parser.getCode() 31 except: 32 self._v_errors = ["Compilation failed", 33 "%s: %s" % sys.exc_info()[:2]] 34 self._v_warnings = parser.getWarnings() 35 self._v_cooked = 1 36 37 pagetemplate.PageTemplate._old_cook = pagetemplate.PageTemplate._old_cook 38 pagetemplate.PageTemplate._cook = cook -
quintagroup.pagetemplateshrink/trunk/setup.py
r1472 r1473 25 25 install_requires=[ 26 26 'setuptools', 27 'Zope>=2.10,<=2.11' 27 28 # -*- Extra requirements: -*- 28 29 ],
Note: See TracChangeset
for help on using the changeset viewer.