# Flon is a package for enabling hand picked Five features in Plone # Copyright (C) 2004 Enfold Systems, LLC # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # """ $Id: __init__.py,v 1.2 2004/07/14 22:23:16 dreamcatcher Exp $ """ from Products.CMFPlone.InterfaceTool import InterfaceTool as BaseTool from Products.Flon.interfaces import IInterfaceTool, ICMFCatalogAware from zope.interface import directlyProvides, directlyProvidedBy, implements from zope.interface import providedBy from zope.app.introspector.interfaces import IIntrospector from zope.app.component.interface import getInterface from zope.app.apidoc.viewmodule import ViewModule class InterfaceTool(BaseTool): """An improved interface tool, with support for introspecting both Zope2 and Zope3 interfaces. Also allows setting marker interfaces directly on objects. """ implements(IInterfaceTool) meta_type = 'Flon Interface Tool' def getDirectlyProvided(self, context): """See IIntrospector""" return IIntrospector(context).getDirectlyProvided() def getDirectlyProvidedNames(self, context): """See IIntrospector""" return IIntrospector(context).getDirectlyProvidedNames() def getMarkerInterfaces(self, context): """See IIntrospector""" return IIntrospector(context).getMarkerInterfaces() def getMarkerInterfaceNames(self, context): """See IIntrospector""" return IIntrospector(context).getMarkerInterfaceNames() def getProvided(self, context): """See IIntrospector""" return providedBy(context) def getProvidedNames(self, context): """See IIntrospector""" provided = providedBy(context) return IIntrospector(context).getInterfaceNames(interfaces=provided) def update(self, context, add=None, remove=None): ob = context if add is not None: for interface in self.getMarkerInterfaceNames(context): if interface in add: interface = getInterface(context, interface) directlyProvides(ob, directlyProvidedBy(ob), interface) if remove is not None: for interface in self.getDirectlyProvidedNames(context): if interface in remove: interface = getInterface(context, interface) directlyProvides(ob, directlyProvidedBy(ob)-interface) if ICMFCatalogAware.providedBy(ob): ob.reindexObject(idxs=['directly_provided', 'provided']) getSkins = ViewModule.getSkins.im_func