[Tutor] Still Trying to Understand GAE
Gerard Flanagan
grflanagan at gmail.com
Wed Sep 16 13:47:51 CEST 2009
admin at gg-lab.net wrote:
> The "google" directoy has an empty __init__.py file (well, if we want
> to be completely correct it contains some commented -#- lines). Same
> for "appengine", "net" and "pyglib". As they all have an __init__.py
> file, they should be consiedered as modules from the python
> interpreter. So, if i run "import google" it imports all google's
> submodules.
>
> Well, now, the problem: if i create another directory (module) in the
> google dir, it doesn't get imported. Of course i've put in it some .py
> files and an empty __init__.py file.
>
>
I would guess that additions have been made to the list of modules in
sys.path. Where the code that is making these additions is located is
another matter. Often, people manipulate sys.path from within
__init__.py files but, as you have seen, this isn't the case for the
google package - all the __init__.py are empty. To verify, navigate to
the GAE directory, the one containing the 'google' package, and start a
python interactive session. Then do
--- import google
--- dir(google)
You don't get 'appengine', 'net' etc. in the output.
So the google package *is* the same as your own package. The confusion
is probably coming from the fact that you are doing your imports from
'within' an already running process - the appserver, and this process
has had a chance to manipulate sys.path before your code runs. Look at
dev_appserver.py in the sdk and google/appengine/tools/dev_appserver.py
- don't ask me what that code is doing, but perhaps there is a clue
there, let us know if you find it!
Regards
More information about the Tutor
mailing list