コード例 #1
0
ファイル: test_composite.py プロジェクト: bendavis78/zope
 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
コード例 #2
0
ファイル: test_composite.py プロジェクト: goschtl/zope
 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
コード例 #3
0
 def setUp(self):
     f = Folder()
     f.getPhysicalPath = lambda: ()
     f.getPhysicalRoot = lambda f=f: f
     f.composite = Composite()
     f.composite._setId("composite")
     t = ZopePageTemplate(
         id="template", text=template_text, content_type="text/html")
     if t.pt_errors():
         raise SyntaxError(t.pt_errors())
     f.composite.template = t
     f.composite.filled_slots.slot_a = slot_a = Slot("slot_a")
     a1 = ZopePageTemplate(id="a1", text="<b>Slot A</b>")
     f._setObject(a1.id, a1)
     e1 = CompositeElement('e1', f.a1)
     slot_a._setObject(e1.id, e1)
     self.composite = f.composite
     self.old_policy = setSecurityPolicy(PermissiveSecurityPolicy())
     noSecurityManager()
コード例 #4
0
    def _make_composite(self):
        from OFS.Folder import Folder
        from ZPublisher.HTTPRequest import HTTPRequest
        from ZPublisher.HTTPRequest import HTTPResponse
        from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
        from Products.CompositePage.composite import Composite
        from Products.CompositePage.element import CompositeElement
        from Products.CompositePage.slot import Slot

        TEMPLATE_TEXT = '\n'.join((
            '<html>',
            '<body>',
            """<div tal:replace="structure slot: slot_a (top) """
            """'Top News Stories'">slot_a</div>""",
            """<span tal:replace="structure slot: slot_b """
            """'Other News'">slot_b</span>""",
            '<div tal:replace="structure context/slots/slot_c">slot_c</div>',
            '</body>',
            '</html>',
        ))
        f = Folder()
        f.getPhysicalPath = lambda: ()
        f.getPhysicalRoot = lambda f=f: f
        req = f.REQUEST = HTTPRequest('', dict(HTTP_HOST='localhost:8080'), {})
        req.response = HTTPResponse()
        f.composite = Composite()
        f.composite._setId("composite")
        t = ZopePageTemplate(id="template",
                             text=TEMPLATE_TEXT,
                             content_type="text/html")
        f.composite.template = t
        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)
        e1 = CompositeElement('e1', f.a1)
        slot_a._setObject(e1.id, e1)
        return f.composite