コード例 #1
0
ファイル: testing.py プロジェクト: vedantc98/Plone-test
    def setUp(self):
        # Stack a new DemoStorage on top of the one from z2.STARTUP.
        self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'),
                                               name='PloneSubRequestFixture')

        # Create a new global registry
        zca.pushGlobalRegistry()
        self['configurationContext'] = context = zca.stackConfigurationContext(
            self.get('configurationContext'))

        # Load out ZCML
        from zope.configuration import xmlconfig
        import plone.subrequest
        xmlconfig.file('testing.zcml', plone.subrequest, context=context)

        with z2.zopeApp() as app:
            # Enable virtual hosting
            z2.installProduct(app, 'Products.SiteAccess')
            from Products.SiteAccess.VirtualHostMonster import \
                VirtualHostMonster
            vhm = VirtualHostMonster()
            app._setObject(vhm.getId(), vhm, suppress_events=True)
            # With suppress_events=False, this is called twice...
            vhm.manage_afterAdd(vhm, app)
            # Setup default content
            app.manage_addFolder('folder1')
            make_site(app.folder1)
            app.folder1.manage_addFolder('folder1A')
            app.folder1.folder1A.manage_addFolder('folder1Ai')
            app.folder1.manage_addFolder('folder1B')
            app.manage_addFolder('folder2')
            make_site(app.folder2)
            app.folder2.manage_addFolder('folder2A')
            app.folder2.folder2A.manage_addFolder('folder2Ai space')
コード例 #2
0
    def setUp(self):
        # Stack a new DemoStorage on top of the one from z2.STARTUP.
        self["zodbDB"] = zodb.stackDemoStorage(self.get("zodbDB"), name="PloneSubRequestFixture")

        # Create a new global registry
        zca.pushGlobalRegistry()
        self["configurationContext"] = context = zca.stackConfigurationContext(self.get("configurationContext"))

        # Load out ZCML
        from zope.configuration import xmlconfig
        import plone.subrequest

        xmlconfig.file("testing.zcml", plone.subrequest, context=context)

        with z2.zopeApp() as app:
            # Enable virtual hosting
            z2.installProduct(app, "Products.SiteAccess")
            from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster

            vhm = VirtualHostMonster()
            app._setObject(vhm.getId(), vhm, suppress_events=True)
            # With suppress_events=False, this is called twice...
            vhm.manage_afterAdd(vhm, app)
            # Setup default content
            app.manage_addFolder("folder1")
            make_site(app.folder1)
            app.folder1.manage_addFolder("folder1A")
            app.folder1.folder1A.manage_addFolder("folder1Ai")
            app.folder1.manage_addFolder("folder1B")
            app.manage_addFolder("folder2")
            make_site(app.folder2)
            app.folder2.manage_addFolder("folder2A")
            app.folder2.folder2A.manage_addFolder("folder2Ai space")
コード例 #3
0
ファイル: Root.py プロジェクト: Python3pkg/Products.Silva
def manage_addRoot(self, id, title, REQUEST=None):
    """Add a Silva root.
    """
    if not title:
        title = id
    if not isinstance(title, str):
        title = str(title, 'latin1')
    id = str(id)
    container = self.Destination()

    # We suppress events are no local utility is present event
    # handlers all fails.
    root = Root(id)
    setattr(root, '__initialization__', True)
    container._setObject(id, root)
    root = container._getOb(id)
    # This root is the new local site where all local utilities (Silva
    # services) will be installed.
    make_site(root)
    setSite(root)
    setHooks()
    try:
        notify(InstallRootServicesEvent(root))
        notify(InstallRootEvent(root))

        root.set_title(title)
        delattr(root, '__initialization__')
        notify(ObjectCreatedEvent(root))

        if REQUEST is not None:
            add_and_edit(self, id, REQUEST)
    except:
        # If there is an error, reset the local site. This prevent
        # more confusion.
        setSite(None)
        setHooks()
        raise
    return root
コード例 #4
0
ファイル: Root.py プロジェクト: silvacms/Products.Silva
def manage_addRoot(self, id, title, REQUEST=None):
    """Add a Silva root.
    """
    if not title:
        title = id
    if not isinstance(title, unicode):
        title = unicode(title, 'latin1')
    id = str(id)
    container = self.Destination()

    # We suppress events are no local utility is present event
    # handlers all fails.
    root = Root(id)
    setattr(root, '__initialization__', True)
    container._setObject(id, root)
    root = container._getOb(id)
    # This root is the new local site where all local utilities (Silva
    # services) will be installed.
    make_site(root)
    setSite(root)
    setHooks()
    try:
        notify(InstallRootServicesEvent(root))
        notify(InstallRootEvent(root))

        root.set_title(title)
        delattr(root, '__initialization__')
        notify(ObjectCreatedEvent(root))

        if REQUEST is not None:
            add_and_edit(self, id, REQUEST)
    except:
        # If there is an error, reset the local site. This prevent
        # more confusion.
        setSite(None)
        setHooks()
        raise
    return root