And here is why GAE loses the path (sometimes)

http://code.google.com/p/googleappengine/issues/detail?id=772#c11

All, this is now an officially acknowledged bug.  The cause is a "feature" which
resets sys.path to a fixed default at the start of each request.  Due to where 
we are
in the QA cycle for the next push it's not going to be fixed until the push 
after
that one, but here is a work-around.  The work-around saves a copy of sys.path 
in a
global variable when main() is called for the first time, and resets sys.path 
to this
value on each subsequent call.  Here is sample code:

import sys
.
. (code that modifies sys.path goes here)
.
ultimate_sys_path = None

def main():
 global ultimate_sys_path
 if ultimate_sys_path is None:
   ultimate_sys_path = list(sys.path)
 else:
   sys.path[:] = ultimate_sys_path
 ... (rest of main goes here) ...

if __name__ == '__main__':
 main()

Reply via email to