### -*- coding: utf-8 -*- ####################################################
##############################################################################
#
# Copyright (c) 2012 Thierry Florac <tflorac AT ulthar.net>
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################


# import standard packages

# import Zope3 interfaces

# import local interfaces
from ztfy.cache.metadirectives import ICacheProxyHandlerBase

# import Zope3 packages
from zope.component.security import PublicPermission
from zope.component.zcml import utility

# import local packages
from ztfy.cache.utility import CacheProxyHandler


def cache_handler(context, name='', cache_interface=None, cache_name=None):
    """Register cache proxy from ZCML"""
    handler = CacheProxyHandler(name, cache_interface, cache_name)
    utility(context, ICacheProxyHandlerBase, component=handler, permission=PublicPermission, name=name)
