[Zope3-dev] more on _clear and the directives registry structure

R. David Murray bitz@bitdance.com
Mon, 16 Sep 2002 01:44:54 -0400 (EDT)


So my simple little program to print out the contents of
the _directives registry works.  I note that all of the
entries conform to either the directive semantics (handler, subdirs)
or the subdirective semantics (subdirs, handler), except for the
entries introduced by '_clear'.  In '_clear' the directive
level is (handler, subdirs), but the subdir level is just (subdirs).

In the function 'sub', the argument 'subs' is split into
base and the subdirectory registry (I'm thinking that it's
getting passed a 'directive' (handler, subdirs) tuple, but
I haven't confirmed that yet).  'subs' is then rebound to
the result of looking up a passed in directive name in the
subdirectory registry.  (This rebinding confused me for a while;
I think it would be less confusing to use a new local variable
for this).

At this point subs has to be a subdirective tuple or (if the
structure used by _clear is valid) a dict.  It seems like the
code expects a dict normally, because there are comments that say
"this is crufty.  if this is a tuple, it means we created it
as such in registersub...."

Now, as far as I can tell, registersub is the normal way
of doing things and only _clear uses the the "other way".
Can we uncruftify this this by fixing _clear and removing the
tuple check, knowing that we are going to get passed a tuple?
Of course, as I said in a previous note, I'd like to reorder
the tuple, too, but that was a separate question <grin>.

--RDM