Short version:
Is there a standard way to bundle Python "back-end server" type code in with a phonegap client application?
Long version:
I have a number of applications that I'm considering porting to phonegap. In general, the apps are written in Python. Some of them have web front-ends, some of them are stand-alone Python apps with interfaces based on wxpython.
So each application has some client-side stuff, which is already in html+javascript+css, or which I'm happy to translate to html+javascript+css.
For the server side, for some of the applications it's okay to leave the server code on a server. But for some/most, I'd like to package the server-side logic in with the phonegap app, so it can be a standalone app. This requirement comes from two needs. One is that many of these apps are used for emergency response, and need to work even when cell towers and other network infrastructure is not available. The other is simply that some of the apps are quite simple, and don't warrant a client/server architecture -- they just happen to have a lot of "back end logic" type code written in Python.
Now, I know that I could just port all of that back-end Python logic to javascript, but I was hoping to find a solution where this sizable code base could remain in Python.
My idea is that I could write a phonegap plugin that actually contains the complete Python interpreter (at least complete enough to handle most of the stuff in my code base). (That is, both iOS and Android allow native C code, so I should be able to compile Python -- or at least much of it -- from source, or just link to iOS and Android Python libraries that others have built.)
So in the javascript code, I could have the client call some function like "InvokeBackEndMethod()". This would act much like an ajax call, but instead of calling out on the network, it would send the query/url/message to the Python plugin. My understanding is that phonegap plugins can maintain persistent state (e.g., a database plugin lets you make one call to open the database and subsequent calls to read from it and close it). So the Python "server" code could maintain its state just like it does on the real server. In fact the Python code might be running a web framework like cherrpy, so it would truly be like running both the client and the server in the same mobile app.
My questions are:
(1) Does that plan sound reasonable?
(2) Has someone already solved this problem? I was hoping to find a project called, say, "phonegap server", and it would essentially be a "universal" PhoneGap extension, in the sense that it would take arbitrary calls from the client, and would dispatch those calls to your choice of various mechanisms: Python, Java, mono, etc. (i.e., this universal phonegap extension would get "extended" by various language "plugins" and then those plugins in turn would get "extended" by whatever business logic the user added in the given language). It may be that such a project isn't needed by most people because they don't have a requirement to run disconnected and/or they don't have a big code base of "back end" logic that they'd like to deploy in a stand-alone app but leave in the original language. But it seems like some people must need that, no?