Пример #1
0
 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
 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
 def _makeContext(self):
     from OFS.Folder import Folder
     root = Folder()
     root.getPhysicalPath = lambda: ('', 'some_path',)
     cm_id = 'http_cache'
     manager = self._makeOne(cm_id)
     root._setObject(cm_id, manager)
     manager = root[cm_id]
     return root, manager
    def _makeContext(self):
        from OFS.Folder import Folder

        root = Folder()
        root.getPhysicalPath = lambda: ("", "some_path")
        cm_id = "http_cache"
        manager = self._makeOne(cm_id)
        root._setObject(cm_id, manager)
        manager = root[cm_id]
        return root, manager
    def _initPAS(self, plugin_type_info=(), plugins={}):
        from OFS.Folder import Folder
        from Products.PluggableAuthService.PluggableAuthService import addPluggableAuthService

        app = Folder()
        app.getPhysicalPath = lambda: ()
        app.getPhysicalRoot = lambda: app

        addPluggableAuthService(app)
        pas = app._getOb("acl_users")

        return app, pas
Пример #6
0
    def _makeSite(self):
        import base64
        from cStringIO import StringIO
        import urllib

        try:
            from OFS.userfolder import UserFolder
        except ImportError:
            # BBB for Zope < 2.13
            from AccessControl.User import UserFolder
        
        from OFS.Folder import Folder
        from OFS.DTMLMethod import DTMLMethod

        root = Folder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous',)

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
        users._doAddUser('isaac', 'pass-w', ('Son',), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        cc.id = self._CC_ID
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager',)
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').rstrip())

        return root, cc, req, credentials
Пример #7
0
    def _makeSite(self):
        import base64
        from cStringIO import StringIO
        import urllib

        try:
            from OFS.userfolder import UserFolder
        except ImportError:
            # BBB for Zope < 2.13
            from AccessControl.User import UserFolder

        from OFS.Folder import Folder
        from OFS.DTMLMethod import DTMLMethod

        root = Folder()
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        root._setObject(users.id, users)

        cc = self._makeOne()
        cc.id = self._CC_ID
        root._setObject(cc.id, cc)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        req = makerequest(root, StringIO())
        self._finally = req.close

        credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').rstrip())

        return root, cc, req, credentials
        def _initPAS(self, plugin_type_info=(), plugins={}):
            from OFS.Folder import Folder
            from Products.PluggableAuthService.PluggableAuthService \
                import addPluggableAuthService

            app = Folder()
            app.getPhysicalPath = lambda: ()
            app.getPhysicalRoot = lambda: app

            addPluggableAuthService(app)
            pas = app._getOb('acl_users')

            return app, pas
Пример #9
0
    def setUp(self):
        CookieCrumblerTests.setUp(self)
        root = Folder()
        self.root = root
        root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
        root.getPhysicalPath = lambda: ()  # hack
        root._View_Permission = ('Anonymous', )

        users = UserFolder()
        users._setId('acl_users')
        users._doAddUser('abraham', 'pass-w', ('Patriarch', ), ())
        users._doAddUser('isaac', 'pass-w', ('Son', ), ())
        users._doAddUser(
            'abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm',
            'pass-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
            ('Son', ), ())
        root._setObject(users.id, users)

        cc = CookieCrumbler()
        cc.id = 'cookie_authentication'
        root._setObject(cc.id, cc)
        self.cc = getattr(root, cc.id)

        index = DTMLMethod()
        index.munge('This is the default view')
        index._setId('index_html')
        root._setObject(index.getId(), index)

        login = DTMLMethod()
        login.munge('Please log in first.')
        login._setId('login_form')
        root._setObject(login.getId(), login)

        protected = DTMLMethod()
        protected._View_Permission = ('Manager', )
        protected.munge('This is the protected view')
        protected._setId('protected')
        root._setObject(protected.getId(), protected)

        self.responseOut = StringIO()
        self.req = makerequest(root, self.responseOut)

        self.credentials = urllib.quote(
            base64.encodestring('abraham:pass-w').replace('\012', ''))
Пример #10
0
  def setUp(self):
    CookieCrumblerTests.setUp(self)
    root = Folder()
    self.root = root
    root.isTopLevelPrincipiaApplicationObject = 1  # User folder needs this
    root.getPhysicalPath = lambda: ()  # hack
    root._View_Permission = ('Anonymous',)

    users = UserFolder()
    users._setId('acl_users')
    users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
    users._doAddUser('isaac', 'pass-w', ('Son',), ())
    users._doAddUser('abrahammmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm',
                     'pass-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
                     ('Son',), ())
    root._setObject(users.id, users)
    
    cc = CookieCrumbler()
    cc.id = 'cookie_authentication'
    root._setObject(cc.id, cc)
    self.cc = getattr(root, cc.id)

    index = DTMLMethod()
    index.munge('This is the default view')
    index._setId('index_html')
    root._setObject(index.getId(), index)

    login = DTMLMethod()
    login.munge('Please log in first.')
    login._setId('login_form')
    root._setObject(login.getId(), login)

    protected = DTMLMethod()
    protected._View_Permission = ('Manager',)
    protected.munge('This is the protected view')
    protected._setId('protected')
    root._setObject(protected.getId(), protected)

    self.responseOut = StringIO()
    self.req = makerequest(root, self.responseOut)

    self.credentials = urllib.quote(
        base64.encodestring('abraham:pass-w').replace('\012', ''))
Пример #11
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()
Пример #12
0
        def _initRegistry(self, plugin_type_info=(), plugins={}):
            from OFS.Folder import Folder
            from OFS.SimpleItem import SimpleItem
            from Products.PluginRegistry.PluginRegistry import PluginRegistry

            app = Folder()
            app.getPhysicalPath = lambda: ()
            app.getPhysicalRoot = lambda: app

            app._setObject('foo_plugin_1', SimpleItem())
            app._setObject('foo_plugin_2', SimpleItem())

            registry = PluginRegistry(plugin_type_info)
            registry._plugins = {}  # it is usually lazy

            for plugin_type, registered in plugins.items():
                registry._plugins[plugin_type] = registered

            app._setObject('plugin_registry', registry)
            registry = app._getOb('plugin_registry')
            return app, registry
Пример #13
0
        def _initRegistry(self, plugin_type_info=(), plugins={}):
            from OFS.Folder import Folder
            from OFS.SimpleItem import SimpleItem
            from Products.PluginRegistry.PluginRegistry import PluginRegistry

            app = Folder()
            app.getPhysicalPath = lambda: ()
            app.getPhysicalRoot = lambda: app

            app._setObject('foo_plugin_1', SimpleItem())
            app._setObject('foo_plugin_2', SimpleItem())

            registry = PluginRegistry(plugin_type_info)
            registry._plugins = {} # it is usually lazy

            for plugin_type, registered in plugins.items():
                registry._plugins[plugin_type] = registered

            app._setObject('plugin_registry', registry)
            registry = app._getOb('plugin_registry')
            return app, registry
Пример #14
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