예제 #1
0
    def test_get_zodb_resources_filter(self):
        app = self.layer['app']

        foo = FilesystemResourceDirectory(
            os.path.join(test_dir_path, 'demo', 'foo'))
        provideUtility(foo, provides=IResourceDirectory, name=u'++demo++foo')

        manifestTest = FilesystemResourceDirectory(
            os.path.join(test_dir_path, 'demo', 'manifest-test'))
        provideUtility(manifestTest,
                       provides=IResourceDirectory,
                       name=u'++demo++manifest-test')

        root = BTreeFolder2('portal_resources')
        app._setOb('portal_resources', root)
        root._setOb('demo', BTreeFolder2('demo'))
        root['demo']._setOb('bar', BTreeFolder2('bar'))
        root['demo']._setOb('baz', BTreeFolder2('baz'))

        persistentDir = PersistentResourceDirectory(root)
        provideUtility(persistentDir,
                       provides=IResourceDirectory,
                       name=u'persistent')

        resources = getZODBResources(TEST_FORMAT,
                                     filter=lambda dir: dir.__name__ != 'baz')

        self.assertEqual(resources, {'bar': None})
예제 #2
0
def getZODBThemes():
    """Get a list of ITheme's stored in the ZODB.
    """

    resources = getZODBResources(MANIFEST_FORMAT, filter=isValidThemeDirectory)
    themes = []
    for name, manifest in resources.items():
        title = name.capitalize().replace('-', ' ').replace('.', ' ')
        description = None
        rules = u"/++%s++%s/%s" % (THEME_RESOURCE_NAME, name, RULE_FILENAME,)
        prefix = u"/++%s++%s" % (THEME_RESOURCE_NAME, name,)
        params = {}
        doctype = ""

        if manifest is not None:
            title = manifest['title'] or title
            description = manifest['description'] or description
            rules = manifest['rules'] or rules
            prefix = manifest['prefix'] or prefix
            params = manifest['parameters'] or params
            doctype = manifest['doctype'] or doctype

        themes.append(Theme(name, rules,
                            title=title,
                            description=description,
                            absolutePrefix=prefix,
                            parameterExpressions=params,
                            doctype=doctype,
                            )
            )

    themes.sort(key=lambda x: x.title)
    return themes
def getZODBThemes():
    """Get a list of newletter themes stored in the ZODB.
    """

    resources = getZODBResources(MANIFEST_FORMAT, filter=isValidThemeDirectory)
    directory = getOrCreatePersistentResourceDirectory()
    themes = []
    for name, manifest in resources.items():
        title = name.capitalize().replace('-', ' ').replace('.', ' ')
        description = None
        template_link = u"/++%s++%s/%s" % (NEWSLETTER_RESOURCE_NAME, name, TEMPLATE_FILENAME,)
        template_content = directory[name].openFile(TEMPLATE_FILENAME).read()
        prefix = u"/++%s++%s" % (NEWSLETTER_RESOURCE_NAME, name,)

        if manifest is not None:
            title = manifest['title'] or title
            description = manifest['description'] or description
            template_link = manifest['template'] or template
            prefix = manifest['prefix'] or prefix


        themes.append(dict(name=name,
                           template_link=template_link,
                           template_content=template_content,
                           title=title,
                           description=description,
                            )
            )

    themes.sort(key=lambda x: x['title'])
    return themes
예제 #4
0
    def test_get_zodb_resources(self):
        app = self.layer['app']

        foo = FilesystemResourceDirectory(os.path.join(test_dir_path, 'demo', 'foo'))
        provideUtility(foo, provides=IResourceDirectory, name=u'++demo++foo')

        manifestTest = FilesystemResourceDirectory(os.path.join(test_dir_path, 'demo', 'manifest-test'))
        provideUtility(manifestTest, provides=IResourceDirectory, name=u'++demo++manifest-test')

        root = BTreeFolder2('portal_resources')
        app._setOb('portal_resources', root)
        root._setOb('demo', BTreeFolder2('demo'))
        root['demo']._setOb('bar', BTreeFolder2('bar'))
        root['demo']._setOb('baz', BTreeFolder2('baz'))

        persistentDir = PersistentResourceDirectory(root)
        provideUtility(persistentDir, provides=IResourceDirectory, name=u'persistent')

        resources = getZODBResources(TEST_FORMAT)

        self.assertEqual(
                resources,
                {'bar': None,
                 'baz': None}
            )
예제 #5
0
def getZODBThemes():
    """Get a list of ITheme's stored in the ZODB.
    """

    resources = getZODBResources(MANIFEST_FORMAT, filter=isValidThemeDirectory)
    themes = []
    for name, manifest in resources.items():
        themes.append(getTheme(name, manifest))

    themes.sort(key=lambda x: x.title)
    return themes
예제 #6
0
def getZODBThemes():
    """Get a list of ITheme's stored in the ZODB.
    """

    resources = getZODBResources(MANIFEST_FORMAT, filter=isValidThemeDirectory)
    themes = []
    for name, manifest in resources.items():
        themes.append(getTheme(name, manifest))

    themes.sort(key=lambda x: x.title)
    return themes