[Zope3-dev] Zip import and sys.path manipulation (was Re: directory hierarchy proposal)
Jim Fulton
jim@zope.com
Mon, 16 Dec 2002 13:04:00 -0500
Guido van Rossum wrote:
>>Alternately, now that there's a "pkgutils" to put it in, why not add a
>>"fileNearModule()" function that returns a file handle opened for reading
>>on the basis of a module name and a file name? I currently use something
>>roughly like:
>>
>>def fileNearModule(moduleName,filename):
>> basedir = os.path.dirname(sys.modules[moduleName].__file__)
>> return open(os.path.join(basedir,filename), 'r')
>>
>>Of course, a zipfile version would need some work, and clearly the zipfile
>>version wouldn't be a candidate for alpha 1.
>>
>>Anyway, if we could establish an API for some of these sorts of things in
>>pkgutils, then they could be the official correct way to get at data files
>>and make zipfiles work for a lot more things long term.
>>
>
> I think Zope3 ought to defines its own API for this, then we can
> decide later on how to do this.
>
> I've seen several places where what you propose isn't enough: when I
> tried putting everything in a zipfile, I ended up giving up when I
> realized that there are places that use os.stat() on filenames thus
> constructed.
This is to ease development. In development mode, we check if the
data on disk has changed and reread it if it has. This wouldn't be
applicable to zip files.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org