Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly implement multiple versions of multiple modules in Google App Engine?

I have been trying to create a Google App Engine project that contains various modules, each with various versions; yet I cannot get it to work.

I went through everything on the google modules guide website but their description of the hierarchy of the application is very vague. I downloaded a simple test application to see how it works (which I cannot get to work).

This is the structure of the application right now: http://www.iteratorium.eu/stackoverflow/structure.jpg

and the whole thing is zipped up here: http://www.iteratorium.eu/stackoverflow/flask_app.zip

There are three modules: default, my-module and mobile-frontend, and both the my-module and mobile-frontend have two versions in directories v_one and v_two. Each version has its own .yaml file, which contains a single handler (keeping it simple for testing purposes)

Is the structure at least correct? When I load the application through the dev_appserver.py file, everything is fine as long as I do not load two versions of the same module. In that case, this happens:

me@MY_COMPUTER:~/flask_app$ python ~/google_appengine/dev_appserver.py dispatch.yaml app.yaml mobile-frontend/v_one/mobile-frontend.yaml my-module/v_one/my-module.yaml my-module/v_two/my-module.yaml

Results in a traceback and the following:

google.appengine.tools.devappserver2.errors.InvalidAppConfigError: Duplicate module: my-module

(Both versions get uploaded onto appengine via appcfg.py without any errors, it might be only the localhost server cannot handle many versions)

If I only load one version of each module, everything works, but the modules cannot import anything from the lib directory. Accessing http://localhost:8082/mobiler through the browser results in this in the terminal:

from flask import Flask
ImportError: No module named flask

I defined the path to the lib folder in the appengine_config.py file but it does not seem to work for the modules. That is where I stopped and decided to come here, since I am not even certain the structure is correct and I might be way off with all of this.

So... How far off am I?

like image 652
Martin Herman Avatar asked Nov 10 '22 06:11

Martin Herman


1 Answers

note: The dev server won't let you load different versions of the same module

You need the module definitions to be in the toplevel dir for appengine_config.py to get loaded.

Considering you really really want to keep the code for the two versions separated, a better app organization would be as follows (just showing mobile-frontend to keep it short):

root
  |__ mobile-frontend
  |   |__ v_one
  |       |__ __init__.py
  |      |__ mobiler.py
  |   |__ v_two
  |       |__ __init__.py
  |       |__ mobiler.py
  |__ appengine_config.py
  |__ dispatch.yaml
  |__ mobile_frontend_v_one.yaml
  |__ mobile_frontend_v_two.yaml

And having mobile_frontend_v_one.yaml being having something like:

handlers:
  - url: .*/mobiler
    script: mobile-frontend.v_one.mobiler.app
like image 95
marianosimone Avatar answered Nov 14 '22 21:11

marianosimone