1
votes

Im studying about GAE, Im trying to build a app with 2 module: default module and count module. Count module increaces value of Count object in datastore by 1 every min. default module access Count object and show its current value.

I setup default module as index.py in root directory.
 Count object in Global.py in /global/
 Count-module as count.py in /count/

I can access Count object form index.py through:

import sys
   sys.path.append(os.path.join(os.path.dirname(__file__), "global"))
   from Global import Count

But I cannot access Count object from count.py in count-module:

 sys.path.append(os.path.join(os.path.dirname(__file__), 
                                            "..",
                                            "global")
                   )
   from Global import Count

--> ImportError: No module named Global Someone help me?

1

1 Answers

1
votes

You don't need folders, but if you do use empty __init__.py inside of each to make them python modules. Your project structure can be:

index.py
count.py
global.py

Then you will be able to import files from each module without changing sys.path. If you want folders then read this answer What is __init__.py for?.

Upd. By the way, use global for module name is bad idea. It is reserved word.