durusmail: quixote-users: Illegal Python Names cookbook recipe
Illegal Python Names cookbook recipe
2004-04-05
2004-04-05
2004-04-05
Bug fixes (was: Illegal Python Names cookbook recipe)
2004-04-07
2004-04-07
Bug fixes (was: Illegal Python Names cookbookrecipe)
2004-04-07
Patches for .7a3
2004-04-07
Re: Patches for .7a3
2004-04-08
StaticFile is broken (Quixote-0.7a3, scgi-1.2a2, Apache/1.3.27, FreeBSD 4.7)
2004-04-08
Re: Patches for .7a3
2004-04-21
2004-04-21
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
Re: Illegal Python Names cookbook recipe
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-08
2004-04-07
2004-04-07
2004-04-07
2004-04-06
2004-04-05
2004-04-05
2004-04-05
Re: R: [Quixote-users] Illegal Python Names cookbook recipe
2004-04-06
Illegal Python Names cookbook recipe
Kendall Clark
2004-04-07
On Tue, Apr 06, 2004 at 09:58:40PM -0400, A.M. Kuchling wrote:

> Possible solution: _q_map is automatically created the first time you
> traverse through an object.  If the object already has a _q_map, the
> contents of _q_exports are merged into _q_map.  So you could include one,
> the other, or both as you see fit.
>
> One worry: mutating _q_map could lead to confusion.  Python doesn't have an
> immutable dictionary type (unless Raymond Hettinger went and added one).

Compared to Neil's patch and the change to _q_exports it provides,
this _q_map interacting with _q_exports seems *far* more complex to
me.

That having been said, I'm not a Quixote core developer, so
implementational complexity is not really my primary concern. Insofar
as I understand Andrew's proposal, I could live with it, I think. At
least, it's better than using _q_lookup or _q_resolve in some cases.

But what would _q_map look like?

1. A list of mapping tuples:

_q_map     = [("style.css", "style_css"),  ("rdf-model", "rdf_model")]

1a. A tuple of mapping tuples:

_q_map     = (("style.css", "style_css"),  ("rdf-model", "rdf_model"))

Which is in keeping with the way GvR distinguishes lists from tuples
(err, I think) and gives you some assurance that it won't be
accidentally mutated behind yr back, though I have no idea if that's
workable.

2. A list (or tuple) of explicit dicts:

_q_map     = [ {"public": "style.css",  "private": "style_css"},
               {"public": "rdf-model",  "private": "rdf_model"} ]

(Other key name possibilities: "internal"/"external", "URI"/"Py". I'd
probably declare a global constant somewhere so that I could do: {PUB:
"style.css", PRIV: "style_css"} but YTMV.)

3. A dict:

_q_map     = {"style.css": "style_css", "rdf-model": "rdf_model"}

Of course,

 - for those who worry about implicitness, you have to remember the
   mapping order with (1), (1a), and (3). Only (2) or (2a) make it
   explicit

 - we would have *two* mechanisms for doing what is essentially the
   same mapping operation

 - what is the semantics when identical items appear in exports and
   map?

Best,
Kendall Clark
--
Jazz is only what you are. --Louis Armstrong



reply