コード例 #1
0
def patch_pagetemplates():
    from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
    from zope.pagetemplate.pagetemplate import _error_start
    # customize `pt_editForm` of ZopePageTemplate
    tmpl = PageTemplateFile('ptEdit', globals(), __name__='pt_editForm')
    tmpl._owner = None
    ZopePageTemplate.pt_editForm = tmpl
    ZopePageTemplate.manage = tmpl
    ZopePageTemplate.manage_main = tmpl
    def get_codemirror_json(self, request):
        error_lines = [int(re.sub(r'.*line ([0-9]+),.*',r'\1',error))
                       for error in getattr(self, '_v_errors', [])
                       if re.match(r'.*line ([0-9]+),.*', error)]
        data = {
            'error_lines': error_lines,
        }
        data.update(_cursor_position(request))
        return json.dumps(data)
    ZopePageTemplate.get_codemirror_json = get_codemirror_json
    original_read = ZopePageTemplate.read
    def read(self, *args, **kwargs):
        text = original_read(self, *args, **kwargs)
        if text.startswith(_error_start):
            errend = text.find('-->')
            if errend >= 0:
                text = text[errend + 3:]
                if text[:1] == "\n":
                    text = text[1:]
        return text
    ZopePageTemplate.read = read
コード例 #2
0
def patch_pagetemplates():
    from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
    from zope.pagetemplate.pagetemplate import _error_start
    # customize `pt_editForm` of ZopePageTemplate
    tmpl = PageTemplateFile('ptEdit', globals(), __name__='pt_editForm')
    tmpl._owner = None
    ZopePageTemplate.pt_editForm = tmpl
    ZopePageTemplate.manage = tmpl
    ZopePageTemplate.manage_main = tmpl

    def get_codemirror_json(self, request):
        error_lines = [
            int(re.sub(r'.*line ([0-9]+),.*', r'\1', error))
            for error in getattr(self, '_v_errors', [])
            if re.match(r'.*line ([0-9]+),.*', error)
        ]
        data = {
            'error_lines': error_lines,
        }
        data.update(_cursor_position(request))
        return json.dumps(data)

    ZopePageTemplate.get_codemirror_json = get_codemirror_json
    original_read = ZopePageTemplate.read

    def read(self, *args, **kwargs):
        text = original_read(self, *args, **kwargs)
        if text.startswith(_error_start):
            errend = text.find('-->')
            if errend >= 0:
                text = text[errend + 3:]
                if text[:1] == "\n":
                    text = text[1:]
        return text

    ZopePageTemplate.read = read
コード例 #3
0
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.ERP5Type import _dtmldir
import os

# Patch for displaying textearea in full window instead of
# remembering a quantity of lines to display in a cookie
pt_editForm = PageTemplateFile(os.path.join(_dtmldir, "ptEdit"), globals(),
                               __name__='pt_editForm' )
pt_editForm._owner = None
ZopePageTemplate.pt_editForm = pt_editForm
ZopePageTemplate.manage = pt_editForm
ZopePageTemplate.manage_main = pt_editForm

コード例 #4
0
ファイル: ZopePageTemplate.py プロジェクト: bhuvanaurora/erp5
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.ERP5Type import _dtmldir
import os

# Patch for displaying textearea in full window instead of
# remembering a quantity of lines to display in a cookie
pt_editForm = PageTemplateFile(os.path.join(_dtmldir, "ptEdit"), globals(), __name__="pt_editForm")
pt_editForm._owner = None
ZopePageTemplate.pt_editForm = pt_editForm
ZopePageTemplate.manage = pt_editForm
ZopePageTemplate.manage_main = pt_editForm