[Zope3-checkins] CVS: Zope3/src/zope/app/component - configure.zcml:1.3 interfacefield.py:1.3
Steve Alexander
steve@cat-box.net
Mon, 30 Dec 2002 13:43:36 -0500
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv29407/src/zope/app/component
Modified Files:
configure.zcml interfacefield.py
Log Message:
Implemented InterfacesField to select several interfaces.
Refined the query interfaces.
=== Zope3/src/zope/app/component/configure.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/component/configure.zcml:1.2 Wed Dec 25 09:12:45 2002
+++ Zope3/src/zope/app/component/configure.zcml Mon Dec 30 13:43:05 2002
@@ -3,59 +3,58 @@
package="zope.component"
>
- <serviceType id='Utilities'
- interface='zope.component.interfaces.IUtilityService' />
- <service serviceType='Utilities'
- permission='zope.Public'
- component='zope.component.utility.utilityService' />
-
- <serviceType id='Adapters'
- interface='zope.component.interfaces.IAdapterService' />
- <service serviceType='Adapters'
- permission='zope.Public'
- component='zope.component.adapter.adapterService' />
-
- <serviceType id='Factories'
- interface='zope.component.interfaces.IFactoryService' />
- <service serviceType='Factories'
- permission='zope.Public'
- component='zope.component.factory.factoryService' />
-
- <serviceType id='Skins'
- interface='zope.component.interfaces.ISkinService' />
- <service serviceType='Skins'
- permission='zope.Public'
- component='zope.component.skin.skinService' />
-
- <serviceType id='Views'
- interface='zope.component.interfaces.IViewService' />
- <service serviceType='Views'
- permission='zope.Public'
- component='zope.component.view.viewService' />
+<serviceType id='Utilities'
+ interface='zope.component.interfaces.IUtilityService' />
+<service serviceType='Utilities'
+ permission='zope.Public'
+ component='zope.component.utility.utilityService' />
- <serviceType id='Resources'
- interface='zope.component.interfaces.IResourceService' />
- <service serviceType='Resources'
- permission='zope.Public'
- component='zope.component.resource.resourceService' />
-
- <hookable name=".getServiceManager" />
+<serviceType id='Adapters'
+ interface='zope.component.interfaces.IAdapterService' />
+<service serviceType='Adapters'
+ permission='zope.Public'
+ component='zope.component.adapter.adapterService' />
+
+<serviceType id='Factories'
+ interface='zope.component.interfaces.IFactoryService' />
+<service serviceType='Factories'
+ permission='zope.Public'
+ component='zope.component.factory.factoryService' />
+
+<serviceType id='Skins'
+ interface='zope.component.interfaces.ISkinService' />
+<service serviceType='Skins'
+ permission='zope.Public'
+ component='zope.component.skin.skinService' />
+
+<serviceType id='Views'
+ interface='zope.component.interfaces.IViewService' />
+<service serviceType='Views'
+ permission='zope.Public'
+ component='zope.component.view.viewService' />
+
+<serviceType id='Resources'
+ interface='zope.component.interfaces.IResourceService' />
+<service serviceType='Resources'
+ permission='zope.Public'
+ component='zope.component.resource.resourceService' />
+
+<hookable name=".getServiceManager" />
+
+<hook module="zope.component"
+ name="getServiceManager"
+ implementation="zope.app.component.hooks.getServiceManager_hook" />
- <hook module="zope.component"
- name="getServiceManager"
- implementation="
- zope.app.component.hooks.getServiceManager_hook" />
-
- <serviceType id='Interfaces'
- interface='zope.app.component.globalinterfaceservice.IInterfaceService' />
-
- <service
- serviceType='Interfaces'
- permission='zope.Public'
- component=
- 'zope.app.component.globalinterfaceservice.interfaceService' />
+<serviceType
+ id='Interfaces'
+ interface='zope.app.component.globalinterfaceservice.IInterfaceService' />
+
+<service
+ serviceType='Interfaces'
+ permission='zope.Public'
+ component='zope.app.component.globalinterfaceservice.interfaceService' />
- <interface interface="zope.interface.Interface" />
+<interface interface="zope.interface.Interface" />
</zopeConfigure>
=== Zope3/src/zope/app/component/interfacefield.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/component/interfacefield.py:1.2 Wed Dec 25 09:12:45 2002
+++ Zope3/src/zope/app/component/interfacefield.py Mon Dec 30 13:43:05 2002
@@ -11,16 +11,16 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""These are the interfaces for the common fields.
-
+"""
$Id$
"""
-from zope.schema import ValueSet
+from zope.schema import ValueSet, Tuple
from zope.interface import Interface
from zope.interface.interfaces import IInterface
from zope.schema.interfaces import ValidationError
from zope.app.interfaces.component.interfacefield import IInterfaceField
+from zope.app.interfaces.component.interfacefield import IInterfacesField
class InterfaceField(ValueSet):
__doc__ = IInterfaceField.__doc__
@@ -41,3 +41,25 @@
if not value.extends(self.type, 0):
raise ValidationError("Does not extend", value, self.type)
+
+class InterfacesField(Tuple):
+ __doc__ = IInterfacesField.__doc__
+ __implements__ = IInterfacesField
+
+ value_type = Interface
+
+ def __init__(self, value_type=Interface, *args, **kw):
+ super(InterfacesField, self).__init__(*args, **kw)
+ self.validate((value_type,))
+ self.value_type = value_type
+ # Not using schema.Sequence.value_types
+
+ def _validate(self, value):
+ super(InterfacesField, self)._validate(value)
+
+ for item in value:
+ if not IInterface.isImplementedBy(item):
+ raise ValidationError("Not an interface", item)
+
+ if not item.extends(self.value_type, 0):
+ raise ValidationError("Does not extend", item, self.value_type)