# Copyright (c) 2002-2008 Infrae. All rights reserved.
# See also LICENSE.txt
# $Revision: 1.2 $

import ViewRegistry, MultiViewRegistry

hasMakeContainerFilter = True
try:
    from Products.Silva.helpers import makeContainerFilter
except:
    hasMakeContainerFilter = False

def initialize(context):
    if hasMakeContainerFilter:
        context.registerClass(
            ViewRegistry.ViewRegistry,
            constructors = (ViewRegistry.manage_addViewRegistryForm,
                            ViewRegistry.manage_addViewRegistry),
            icon = "www/silva_view_registry.gif",
            container_filter = makeContainerFilter()
            )

        context.registerClass(
            MultiViewRegistry.MultiViewRegistry,
            constructors = (MultiViewRegistry.manage_addMultiViewRegistryForm,
                            MultiViewRegistry.manage_addMultiViewRegistry),
            icon = "www/silva_multi_view_registry.gif",
            container_filter = makeContainerFilter()
            )
    else:
        context.registerClass(
            ViewRegistry.ViewRegistry,
            constructors = (ViewRegistry.manage_addViewRegistryForm,
                            ViewRegistry.manage_addViewRegistry),
            icon = "www/silva_view_registry.gif"
            )

        context.registerClass(
            MultiViewRegistry.MultiViewRegistry,
            constructors = (MultiViewRegistry.manage_addMultiViewRegistryForm,
                            MultiViewRegistry.manage_addMultiViewRegistry),
            icon = "www/silva_multi_view_registry.gif"
            )



