[Zope3-checkins] CVS: Zope3/lib/python/Zope/Configuration - meta.py:1.15.4.2

R. David Murray bitz@bitdance.com
Mon, 21 Oct 2002 19:14:04 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Configuration
In directory cvs.zope.org:/tmp/cvs-serv11649

Modified Files:
      Tag: rdmurray-metameta-branch
	meta.py 
Log Message:
Remove my temporary hack in meta.py.  Subsequent checkins will fix
the implementation declarations of the various INonEmptyDirectives.
In some cases this means changing an incorrect __implements__ to a
__class_implements__, in others it means adding the __class_implements__.

I debated the wisdom of this change, but it seems to me that depending
on the subdirective dictionary being non-empty to signal which kind
of object is getting returned is very fragil.  Consider the
not-too-unlikely development scenario of temporarily removing your
subdirective declarations from your meta.zcml file.  Suddenly your
code breaks, even though your Directive class hasn't changed.
Better, I think, to have the code fail right away if you forgot or
messed up your Interface declaration.  Explicit is better than
implicit.


=== Zope3/lib/python/Zope/Configuration/meta.py 1.15.4.1 => 1.15.4.2 ===
--- Zope3/lib/python/Zope/Configuration/meta.py:1.15.4.1	Mon Oct 14 18:34:32 2002
+++ Zope3/lib/python/Zope/Configuration/meta.py	Mon Oct 21 19:14:03 2002
@@ -161,15 +161,7 @@
 
     r = callable(context, **kw)
 
-    #XXX This _metadataKey check is a temporary hack.  I really want this
-    # line to just be "if INonEmptyDirective.isImplementedBy(callable):",
-    # but to achieve that I have to go through and put the correct
-    # declarations on all the current directive classes and functions,
-    # and I don't want to do that until I know this branch is going to
-    # be accepted.
-    _metadataKey = "__Zope.Configuration.metadataKey__"
-    if (len(subs)>1 or (len(subs)==1 and not subs.has_key(_metadataKey))
-            or INonEmptyDirective.isImplementedBy(callable)):
+    if INonEmptyDirective.isImplementedBy(callable):
         return r, subs
     else:
         return (