当前位置: 首页>>代码示例>>Python>>正文


Python ZopePageTemplate.ZopePageTemplate类代码示例

本文整理汇总了Python中Products.PageTemplates.ZopePageTemplate.ZopePageTemplate的典型用法代码示例。如果您正苦于以下问题:Python ZopePageTemplate类的具体用法?Python ZopePageTemplate怎么用?Python ZopePageTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ZopePageTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_mail_body

    def get_mail_body(self, fields, request, context):
        """Returns the mail-body with footer.
        """

        schema = get_fields(context)
        all_fields = [f for f in fields
                      # TODO
                      # if not (f.isLabel() or f.isFileField()) and not (getattr(self,
                      # 'showAll', True) and f.getServerSide())]
                      if not (INamedFile.providedBy(fields[f])) and not (getattr(self, 'showAll', True) and IFieldExtender(schema[f]).serverSide)
                      ]

        # which fields should we show?
        if getattr(self, 'showAll', True):
            live_fields = all_fields
        else:
            live_fields = [
                f for f in all_fields if f in getattr(self, 'showFields', ())]

        if not getattr(self, 'includeEmpties', True):
            all_fields = live_fields
            live_fields = [f for f in all_fields if fields[f]]
            for f in all_fields:
                value = fields[f]
                if value:
                    live_fields.append(f)

        #bare_fields = [schema[f] for f in live_fields]
        bare_fields = dict([(f, fields[f]) for f in live_fields])
        bodyfield = self.body_pt

        # pass both the bare_fields (fgFields only) and full fields.
        # bare_fields for compatability with older templates,
        # full fields to enable access to htmlValue
        replacer = DollarVarReplacer(fields).sub
        extra = {
            'data': bare_fields,
            'fields': dict([(i, j.title) for i, j in getFieldsInOrder(schema)]),
            'mailer': self,
            'body_pre': self.body_pre and replacer(self.body_pre),
            'body_post': self.body_post and replacer(self.body_post),
            'body_footer': self.body_footer and replacer(self.body_footer),
        }
        template = ZopePageTemplate(self.__name__)
        template.write(bodyfield)
        template = template.__of__(context)
        body = template.pt_render(extra_context=extra)

        # if isinstance(body, unicode):
            #body = body.encode("utf-8")

        #keyid = getattr(self, 'gpg_keyid', None)
        #encryption = gpg and keyid

        # if encryption:
            #bodygpg = gpg.encrypt(body, keyid)
            # if bodygpg.strip():
                #body = bodygpg

        return body
开发者ID:hvelarde,项目名称:collective.easyform,代码行数:60,代码来源:actions.py

示例2: _make_composite

 def _make_composite(self):
     from OFS.Folder import Folder
     f = Folder()
     f.getPhysicalPath = lambda: ()
     f.getPhysicalRoot = lambda f=f: f
     from ZPublisher.HTTPRequest import HTTPRequest
     f.REQUEST = HTTPRequest('', dict(HTTP_HOST='localhost:8080'), {})
     from Products.CompositePage.composite import Composite
     f.composite = Composite()
     f.composite._setId("composite")
     from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
     t = ZopePageTemplate(
         id="template", text=template_text, content_type="text/html")
     f.composite.template = t
     from Products.CompositePage.slot import Slot
     f.composite.filled_slots.slot_a = slot_a = Slot("slot_a")
     t = f.composite.template
     if t.pt_errors():
         raise SyntaxError(t.pt_errors())
     a1 = ZopePageTemplate(id="a1", text="<b>Slot A</b>")
     f._setObject(a1.id, a1)
     from Products.CompositePage.element import CompositeElement
     e1 = CompositeElement('e1', f.a1)
     slot_a._setObject(e1.id, e1)
     return f.composite
开发者ID:goschtl,项目名称:zope,代码行数:25,代码来源:test_composite.py

示例3: manage_afterAdd

 def manage_afterAdd(self, item, container):
     """ Setup tasks upon instantiation """
     if not 'lockout' in self.objectIds():
         lockout = ZopePageTemplate(id='lockout', text=BASIC_LOCKOUT)
         lockout.title = 'User Lockout'
         lockout.manage_permission(view, roles=['Anonymous'], acquire=1)
         self._setObject('lockout', lockout, set_owner=0)
开发者ID:fourdigits,项目名称:Products.LoginLockout,代码行数:7,代码来源:plugin.py

示例4: __init__

    def __init__(self, id, filepath, fullname, properties):
        """ Initialise a new instance of XMLTemplate.

        """
        FSObject.__init__(self, id, filepath, fullname, properties)
        self.ZBindings_edit(self._default_bindings)
        
        self.__name__ = id
        self.title = id
        self.id = id
        
        self._setPropValue('content_type', 'text/xml')

        self.setup_transformProperties()
        self.setup_schemaProperties()
        
        try:
            fp = expandpath(self._filepath+'.propsheet')
            prop_map = parsePropertiesFile(fp, 1)
            for propdict in prop_map:
                setattr(self, propdict['id'], propdict['default_value'])
            self._properties = prop_map
        except:
            raise
        
        ZopePageTemplate.__init__(self, id)            
开发者ID:groupserver,项目名称:Products.DataTemplates,代码行数:26,代码来源:FSXMLTemplate.py

示例5: test_cook_zope2_page_templates_good_format_attr_unicode

 def test_cook_zope2_page_templates_good_format_attr_unicode(self):
     from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
     pt = ZopePageTemplate('mytemplate', GOOD_FORMAT_ATTR_UNICODE)
     hack_pt(pt, self.app)
     self.assertEqual(
         pt.pt_render().strip(),
         '<p>title of &lt;Application at &gt; is Zope</p>')
开发者ID:zopefoundation,项目名称:Zope,代码行数:7,代码来源:test_safe_formatter.py

示例6: test_cook_zope2_page_templates_good_format_attr_str

 def test_cook_zope2_page_templates_good_format_attr_str(self):
     from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
     pt = ZopePageTemplate('mytemplate', GOOD_FORMAT_ATTR_STR)
     hack_pt(pt, self.portal)
     self.assertEqual(
         pt.pt_render().strip(),
         '<p>title of &lt;PloneSite at plone&gt; is Plone site</p>')
开发者ID:zmijunkie,项目名称:Products.CMFPlone,代码行数:7,代码来源:test_safe_formatter.py

示例7: _createZODBClone

 def _createZODBClone(self):
     """
         Create a ZODB (editable) equivalent of this object.
     """
     target = ZopePageTemplate(self.getId(), _CUSTOMIZED_TEMPLATE_ZPT)
     target._setProperty('rest', self.raw, 'text')
     return target
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:7,代码来源:FSReSTMethod.py

示例8: test_access_to_private_content_not_allowed_via_rich_text

    def test_access_to_private_content_not_allowed_via_rich_text(self):
        try:
            from plone.app.textfield.value import RichTextValue
        except ImportError:
            return
        from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
        foobar = create_private_document(self.portal, 'foobar')
        login(self.portal, TEST_USER_NAME)
        foobar.text = RichTextValue(u'Secret.', 'text/plain', 'text/html')
        self.assertEqual(
            self.portal.portal_workflow.getInfoFor(foobar, 'review_state'),
            'private')

        # Check that guarded_getattr is happy for the current user.
        self.assertEqual(guarded_getattr(self.portal, 'foobar'), foobar)
        self.assertEqual(
            guarded_getattr(self.portal.foobar, 'text'), foobar.text)
        # Access to text.output may be more restricted than access to the
        # text object itself, but this makes no sense, so we switch that
        # off in this test.
        # self.assertRaises(
        #     Unauthorized, guarded_getattr, self.portal.foobar.text, 'output')
        self.portal.foobar.text.__allow_access_to_unprotected_subobjects__ = 1
        self.assertEqual(
            guarded_getattr(self.portal.foobar.text, 'output'),
            '<p>Secret.</p>')
        TEMPLATE = '<p tal:content="structure python:%s" />'
        pt = ZopePageTemplate(
            'mytemplate', TEMPLATE %
            "'access {0.foobar.text.output}'.format(context)")
        hack_pt(pt, context=self.portal)
        self.assertEqual(pt.pt_render(), '<p>access <p>Secret.</p></p>')

        # Check the same for anonymous.
        logout()
        self.assertRaises(
            Unauthorized, guarded_getattr, self.portal, 'foobar')
        self.assertRaises(
            Unauthorized, guarded_getattr, self.portal.foobar, 'text')
        # *If* somehow anonymous can access the text, then we have allowed
        # access to the output as well.
        self.assertEqual(
            guarded_getattr(self.portal.foobar.text, 'output'),
            '<p>Secret.</p>')
        # But for the template anonymous would need access to everything,
        # which rightly fails.
        self.assertRaises(Unauthorized, pt.pt_render)

        # Test the simpler access without str.format for the current user.
        login(self.portal, TEST_USER_NAME)
        pt = ZopePageTemplate(
            'mytemplate', TEMPLATE %
            "context.foobar.text.output")
        hack_pt(pt, context=self.portal)
        self.assertEqual(pt.pt_render(), '<p><p>Secret.</p></p>')

        # and for anonymous
        logout()
        self.assertRaises(Unauthorized, pt.pt_render)
开发者ID:zmijunkie,项目名称:Products.CMFPlone,代码行数:59,代码来源:test_safe_formatter.py

示例9: test_cook_zope2_page_templates_good_unicode

 def test_cook_zope2_page_templates_good_unicode(self):
     from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
     pt = ZopePageTemplate('mytemplate', unicode(GOOD_UNICODE))
     hack_pt(pt)
     self.assertEqual(pt.pt_render().strip(), '<p>none</p>')
     hack_pt(pt, self.portal)
     self.assertEqual(
         pt.pt_render().strip(), '<p>&lt;plonesite at plone&gt;</p>')
开发者ID:zmijunkie,项目名称:Products.CMFPlone,代码行数:8,代码来源:test_safe_formatter.py

示例10: manage_afterAdd

 def manage_afterAdd(self, item, container):
     """ Setup tasks upon instantiation """
     login_form = ZopePageTemplate( id='login_form'
                                  , text=BASIC_LOGIN_FORM
                                  )
     login_form.title = 'Login Form'
     login_form.manage_permission(view, roles=['Anonymous'], acquire=1)
     self._setObject( 'login_form', login_form, set_owner=0 )
开发者ID:goschtl,项目名称:zope,代码行数:8,代码来源:CookieAuthHelper.py

示例11: test_cook_zope2_page_templates_good_str

 def test_cook_zope2_page_templates_good_str(self):
     from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
     pt = ZopePageTemplate('mytemplate', GOOD_STR)
     hack_pt(pt)
     self.assertEqual(pt.pt_render().strip(), '<p>none</p>')
     hack_pt(pt, context=self.portal)
     self.assertEqual(
         pt.pt_render().strip(), '<p>&lt;plonesite at plone&gt;</p>')
开发者ID:zmijunkie,项目名称:Products.CMFPlone,代码行数:8,代码来源:test_safe_formatter.py

示例12: test_cook_zope2_page_templates_good_unicode

 def test_cook_zope2_page_templates_good_unicode(self):
     from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
     pt = ZopePageTemplate('mytemplate', GOOD_UNICODE)
     hack_pt(pt)
     self.assertEqual(pt.pt_render().strip(), '<p>none</p>')
     hack_pt(pt, self.app)
     self.assertEqual(
         pt.pt_render().strip(), '<p>&lt;application at &gt;</p>')
开发者ID:zopefoundation,项目名称:Zope,代码行数:8,代码来源:test_safe_formatter.py

示例13: test_use_as_macro

 def test_use_as_macro(self):
     use_macro = ZopePageTemplate(id='use_macro').__of__(self.portal)
     use_macro.pt_edit(use_macro_zpt, 'text/html')
     self.assertEqual(use_macro(),
         '\n<div class="left_portlet">\n'
         '\t<div class="left_portlet_title">new title</div>\n'
         '\t<div class="left_portlet_content">PORTLET CONTENT</div>\n'
         '</div>\n')
开发者ID:eaudeweb,项目名称:Products.Naaya,代码行数:8,代码来源:test_disktemplate.py

示例14: test_template_translation

        def test_template_translation(self):
            tmpl = ZopePageTemplate(id='test_tmpl')
            tmpl.pt_edit('<p i18n:translate="">Home for'
                              ' <span i18n:name="hours">3</span> hours</p>',
                              'text/html')

            self.assertEqual(tmpl.__of__(self.portal)(),
                             u'<p>Home for <span>3</span> hours</p>\n')
开发者ID:eaudeweb,项目名称:naaya.i18n,代码行数:8,代码来源:test_translations_tool_wrapper.py

示例15: body_compile

 def body_compile(self):
     if not self.body:
         return ''
     pt = ZopePageTemplate(id='__adv_page_tal_body__')
     pt.pt_edit(self.body, 'text/html')
     context = aq_inner(self)
     pt = aq_base(pt).__of__(context)
     # request is taken by acquisition
     return pt()
开发者ID:simahawk,项目名称:collective.advancedpage,代码行数:9,代码来源:advancedpage.py


注:本文中的Products.PageTemplates.ZopePageTemplate.ZopePageTemplate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。