On Feb 24, 2004, at 12:54 AM, Mitch Chapman wrote:
On Feb 23, 2004, at 8:04 PM, Bob Ippolito wrote:
Extracting data from zip files is not strictly desired or necessary
as we have bundles on OS X, temp files suck, most data files
probably aren't going to compress very well anyhow.
Things I don't like about this implementation:
* It's up to the module developer to ensure that their
"images/sample.jpg" is a unique filename that another module
developer will not use or else PathFinder might find the wrong file.
This is very bad, because if the module developers can screw this
up they definitely will. Forcing them to specify a key, like
__name__ or perhaps "org.pygame", is more sensible because it
isolates packages from each other.
I think you may have misread the code. PathFinder uses the same path
resolution techniques as Python itself (with the exception that it
doesn't use sys.meta_path). That is, it searches every
entry on sys.path, seeing if the relative path supplied by the caller
can be resolved by joining with the current sys.path entry.
But the python import mechanism knows what module you're importing
from, your API does not. sys.path is a fallback mechanism gets used
if the module can not be found relative to the module doing the
importing. Your mechanism ONLY uses the fallback mechanism, so if
pygame wants "image/sample.jpg" and foobazmodule wants
"image/sample.jpg", it's not really possible to have both of them get
what they want without an API change.
The changes relating to zip file support are intended to mimic
Python 2.3's support for importing from zip files. They do not
require
that the user's content be packaged in zip files.
That's fine, I just don't think it's necessary. In any case, a more
flexible version based on interfaces and adaptation would allow
artbitrary-packaging-software to provide zip, rar, http, encrypted, or
whatever data file support it needs.
Just to clarify, when I say interfaces and adaptation, I really mean "a
global registry somewhere so the default implementation can be
overridden", not unlike sys.path and import hooks. PyProtocols is just
a great example of a well designed central registry with a lot of
features that would make something like this extremely trivial, and it
even has a PEP behind it. Zope X3's components, and Twisted's
components are both also potentially usable (though the protocolForURI
feature is key, and I'm not sure if either has that), but are far less
generic and flexible (PyProtocols is actually flexible enough to
integrate with either, but not vice versa).