Kristian Damian Kristian Damian - 10 months ago 68
Python Question

App engine read DataStore data between modules

I have a app divided in 5 modules (see my beautiful ascii art) Each have their own directory, just like this structure

AppEngine App <--Here's the dispatch.yaml
| | | | |
| | | | |
Mod1 Mod2 Mod3 Mod4 Mod5
^ ^
\__Here's the models |__ Here i wanna read the models
.py file
with the

The NDB models are defined in one module (mod1 by example) and i wanna read some data in the Mod5, the official documentation says that's posible, but i can't do it. I'm importing the model in this ways

#this is in mod5 py file
import Mod1.models # No module named Mod1.models
from Path.Mod1 import models #No module named Path.Mod1
from Mod1 import models #No module named Mod1
from Mod1.models import specific_model #No module named Mod1.models
from Path.models import specific_model #No module named Path.models

I change the --storage_path setting to each module to be able tu run all modules at the same time in the launcher, i think that could be the problem. But if i leave the same directory how can run at the same time all the modules (i got "OperationalError: database is locked" error)
Any clue here?

Answer Source

I found a answer, not ideal, but works.

If i clone (A.K.A copy-paste) the file in the Mod5 folder and remove the --storage_path setting (the db is shared in the same temp folder in the develop server) i can read the data stored.

Obviously the models needs to be sync in EVERY change, but at least i can move forward in my code

The directory structure stay as follows:

-- Main (with the dispatch.yaml)
 |__ Mod1
 |      |__
 |      |__ app.yaml
 |      |__
 |      |______ Templates
 |      |______ js
 |      |______ css
 |      |______ img
 |__ Mod5
        |__ #equal that mod1
        |__ app.yaml #with the mod5 instace and stuff
        |______ Templates
        |______ js
        |______ css
        |______ img

To run all the modules at the same time it's necesary run the dev_appserver command in the root directory of the app (source)

python mod1\app.yaml mod2\app.yaml mod3\app.yaml mod4\app.yaml mod5\app.yaml

Runnind in this URL's

Mod1=> localhost:8080

Mod2=> localhost:8081

Mod3=> localhost:8082

Mod4=> localhost:8083

Mod5=> localhost:8084