[Zope-Checkins] CVS: Zope/lib/python/ComponentArchitecture - Presentation.py:1.1.4.5
Shane Hathaway
shane@digicool.com
Fri, 28 Sep 2001 14:02:25 -0400
Update of /cvs-repository/Zope/lib/python/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv7308
Modified Files:
Tag: ComponentArchitecture-branch
Presentation.py
Log Message:
Check interface of component after binding
=== Zope/lib/python/ComponentArchitecture/Presentation.py 1.1.4.4 => 1.1.4.5 ===
"""
-import Errors
import Interface
from Interface import objectImplements
+from Acquisition import ExplicitAcquisitionWrapper
+import Errors
from Service import Service, findComponent
from IToIRegistry import IToIRegistry
+
_marker = [] # Create a new marker object.
@@ -111,6 +113,7 @@
_global_regs = {} # name -> IToIRegistry
def registerPresentation(input, name, output, unbound_comp):
+ # assert unbound_comp.allowsBindingTo(input)
reg = _global_regs.get(name, None)
if reg is None:
_global_regs[name] = reg = IToIRegistry()
@@ -138,4 +141,12 @@
else:
raise Errors.PresentationNotFound(object, name)
# Bind the component.
- return c(object)
+ r = c(object)
+
+ assert output.isImplementedBy(r), '%s does not implement %s' % (
+ `output`, `r`)
+
+## if not hasattr(r, 'aq_base'):
+## # XXX Add an acquisition wrapper.
+## r = ExplicitAcquisitionWrapper(r, object)
+ return r