[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IToIRegistry.py:1.1.4.9
Martijn Pieters
mj@zope.com
Wed, 13 Feb 2002 00:03:37 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv14206/ComponentArchitecture
Modified Files:
Tag: Zope-3x-branch
IToIRegistry.py
Log Message:
Optimizations and code style updates:
- Use isinstance on type checks
- Test UnicodeType and StringType through StringTypes
- Remove use of the string module
- Use startswith and endswith instead of slices.
- Fix weird tests where isinstance suffices.
=== Zope3/lib/python/Zope/ComponentArchitecture/IToIRegistry.py 1.1.4.8 => 1.1.4.9 ===
from Interface.Util import objectImplements
from Exceptions import Invalid
+from types import ListType, TupleType
class IToIRegistry: # Interface to Interface
@@ -45,11 +46,12 @@
self._registerAll(require, primary_provide, c, base)
- def register(self, require, provide, maker):
+ def register(self, require, provide, maker,
+ ArrayTypes=(ListType, TupleType)):
'''
Registers a component.
'''
- if type(maker) not in (type([]), type(())):
+ if not isinstance(maker, ArrayTypes):
maker = [maker]
if not maker == filter(callable, maker):
raise TypeError("The registered component callable is not "