Changeset 1473 in products


Ignore:
Timestamp:
Dec 25, 2009 2:02:06 PM (14 years ago)
Author:
chervol
Message:

the patchcode added

Location:
quintagroup.pagetemplateshrink/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.pagetemplateshrink/trunk/quintagroup/pagetemplateshrink/__init__.py

    r1472 r1473  
    11# 
     2from zope.pagetemplate import pagetemplate 
     3 
     4import re 
     5expression = re.compile('[ \n\f\r]+(?=</?(?:me)?tal)') 
     6expression2 = re.compile('\n\s*\n+(?= *<)') 
     7 
     8def 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 
     37pagetemplate.PageTemplate._old_cook = pagetemplate.PageTemplate._old_cook 
     38pagetemplate.PageTemplate._cook = cook 
  • quintagroup.pagetemplateshrink/trunk/setup.py

    r1472 r1473  
    2525      install_requires=[ 
    2626          'setuptools', 
     27          'Zope>=2.10,<=2.11' 
    2728          # -*- Extra requirements: -*- 
    2829      ], 
Note: See TracChangeset for help on using the changeset viewer.