Ticket #250 (closed enhancement: fixed)
Problems with Importing and reloading files
| Reported by: | nick | Owned by: | feisley |
|---|---|---|---|
| Priority: | critical | Milestone: | 0.3 |
| Component: | Utility | Version: | 0.3 |
| Keywords: | Cc: | ||
| Fixed in revision: | Branch: | ||
| Author: |
Description
Django, Pylons and the Google App Engine dev server all have the facility to check the timestamps of all loaded modules to check if any changes have been made since the last request. This allows changes to be made to the code without restarting the server each time.
The Importing module creates a system module that imports the real module when an attribute is accessed on it. According to PEP 302 custom import modules must define a few attributes (including __name__, __file__ etc.). These attributes are used by the frameworks listed above to determine if the file that the module is based on has changed.
An example: The PyAMF adapter framework currently defines an adapter for Django. If the module django is not imported properly before the reload check is started, all frameworks will throw an error, based on the fact that the modules do not define the correct attributes.
The problem here is that if you attempt to set/get an attribute for the lazily imported module, the whole module is imported, which is not the desired response.
We need to find a way to set the __file__ and __name__ attributes without firing a complete import of the module in question.


