Ken Manheimer wrote:
On Tue, 25 Jan 2000, Skip Montanaro wrote:
Guido> Skip: >> I'd like to propose a third alternative. How about if the string >> interpolation function accepted a tuple of dictionaries directly: >> >> s = format % (d1, d2) [...] Guido> I think it depends on to what extent this is a common, useful Guido> idiom. Do you have evidence of that? Examples?
Well, the first place I ran into it was in DocumentTemplates a few years ago. They used an idiom heavily which may have now been replaced by acquisition where you'd effectively push and pop value dicts onto a stack as you entered and exited nested blocks of DTML code. Their solution was a special dict-like object.
Implementation of acquisition basically uses a MultiDict underneath.
No it doesn't. Acquisition achieves combination of multiple namespaces in much the same way that inheritence does (through delagation).
Consider acquisition as a cumulative context composed from the containers of the target of a web request. (Actually, a distinction is made between the object containment hierarchy of the target and the successive components of the path along which the target is reached by the request, with the containment contexts taking precedence - but that's probably not important here:-) Add in incidental things like the server environment (from which you can get HTTP_REFERER and cookies and so forth). Each of the components can be a dictionary or a MultiDict (or a sequence of pairs, i think), and they're ultimately composed in a MultiDict.
I think another place in zope where multidicts play prominently is in the security mechanism, where any object can have local roles, and the ultimate role of a user within a context is composed from the union across the containment hierarchy. There probably are lots of other places where multidicts are used.
Acquisition plays a role in security, but MultiDicts-like things are not used.
Suffice to say that there's a lot of composing of contexts that goes on in Zope in general, acquistion being a prime example but not the only one, and multidicts play heavily in many. I would be surprised if this need to combine contexts is peculiar to web server, or general server applications.
[...] It's not a big deal. If it seems too obscure the other obvious solutions are not gruesome.
I suppose we'd be pretty happy to have something like MultiDict as part of python...
Note that Zope actually uses two separate flavors. The one used most in Zope (in DocumentTemplate) has very specific hooks to work with Zope's security machinery. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.