I have two different projects in Google app engine account. The folders structure in my computer is as following:
- parent_folder
- common_folder
- project1_folder
- project2_folder
I have few python classes in common_folder that I want to use in both projects (project1 and project2).
I want to import the common classes into my projects, so Google App Engine will recognize them also on Production env (maybe GAE can create a copy of the common files when uploading?)
I tried using the following code in order to import my class from a specific parent directory path:
import os
PARENT_DIR = os.path.dirname(os.path.dirname(__file__))
print PARENT_DIR
def load_src(name, fpath):
import os, imp
return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath))
load_src("globals", PARENT_DIR +"/common/globals.py")
from globals import *
This code worked only from my localhost environment but when I uploaded it to GAE, it didn't recognize the class:
> File
> "/base/data/home/apps/s~loan-management-system/1.394267205500555512/main.py",
> line 39, in load_src
> return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath)) IOError: [Errno 2] No
> such file or directory