[Zope] Opinions sought on acquisition issue
The Famous Brett Watson
famous@nutters.org
Fri, 30 Mar 2001 11:44:48 +1000
Hello folks. I encountered an issue whilst site-tweaking last night and
solved it immediately, but it has me intrigued as to how more experienced
Zopists than I might approach it. Any wisdom you'd care to share on the
matter would be appreciated.
I have a site which includes a "weblog" type arrangement, and I keep the log
entries in a folder called "log". There's a subfolder called "images" for
pictures that I might want to include in log entries. There's also an
"images" folder in the root directory for site-wide graphics such as the
site logo. Thus, in the context of the "log" folder, "images" means the
log-specific images only. This means I can't address the site-wide image
objects in this context without reference to PARENTS[-1] or similar. {Side
issue: wouldn't it make sense to have "ROOT" or similar as an alias for
PARENTS[-1]?} Specifically, I can't say "images['site-logo.jpg']" in a
Python expression, since it will look in the wrong "images" container.
I resolved this issue by renaming "images" in the "log" directory to
"log_images", thus ensuring that they have distinct names. I was planning on
making this distinct-naming my general approach in future. The "images" name
makes more sense from a URL perspective, but the "log_images" name makes
more sense from an acquisition perspective.
The reason that this is an issue at all, however, is because
identically-named container objects to not acquire the contents of the
containers they mask, if any. The "images" folder in the "log" folder masks
the "images" folder at the root, thus *hiding* the contents of that folder
rather than *acquiring* the contents of that folder. What would the
implications be for Zope if acquisition meant that a failed method
invocation resulted in further traversal of the namespace stack instead of
immediate failure? Thus, if I try to reference "images['site-logo.jpg']",
and the first "images" object found does not contain 'site-logo.jpg', would
it be a good, bad, or ugly thing for Zope to *continue* the search for
"images" objects containing a 'site-logo.jpg'?
A container's contents might not be the only thing one could acquire in this
manner: perhaps other methods could also perform some kind of continued
search for success if they encounter an exception early on? This might get
very confusing.
I await with interest your pontifications on this matter.
Regards,
TFBW