Uploading a simple web2py app to GAE - google-app-engine

I created a web2py app that is extremely light, with the goal of eventually making the app support JSON-RPC calls, and maybe a few other things.
I found some tutorial online that (on winxp) had me get the source code for web2py and extract it on top of the compiled program. At the top level, I edited app.yaml with my program name and used the GAE SDK to upload the program. It looks like that uploaded everything including example applications. I think it's including a whole gluon directory, and other dir's full of py files. Is there a way to setup web2py to only upload my application, and what's minimally required to run it?

The app.yaml that comes with web2py includes a section skip_files and it should contain, among others, this line:
(applications/(admin|examples)/.*)|
You can change it to
(applications/(admin|examples|welcome)/.*)|
So that welcome app is not deployed. You add more apps that you may have and do not want deployed.
At minimum you need:
web2py/gaehandler.py
web2py/gluon/* (and subfolders, this is web2py)
web2py/applications/theoneappyouwanttodeploy/* (and subfolders)

Related

Several host page compile full project

I have a GWT application that use and have 2 host pages with 2 differents EntryPoint (gwt.xml files) which some code and most important, Database (datastore in Google App Engine) common.
The problem is that one of them makes use of several external Java libraries, including SmartGWT with its JS, meanwhile the second one use none of them. When I deploy (and compile) to Google App Engine, I need to include reference in the second entry point to SmartGWT, although it's not used. If inherits directive lacks, I get lot of compilation errors. I don't want to load SmartGWT JS files (2 MBytes) when they are not necessary, growing download from a few Kbytes to 100x times Kilobytes with SmartGWT. This second host page is a Google Chrome Extension, where light load is a strong requirement.
If I run in GAE SDK eclipse local webserver without any reference to SmartGWT in second host page, it works. But if I compile the whole project (although in first hots page references to SmartGWT remains) I get errors, related to SmartGWT absence.
Is it possible to make a separate compilation of two host pages?
Your project appears to be burdened with a dependency of questionable value. If your project does not make heavy use of GWT, consider rewriting your web pages to not use GWT. In some cases a framework has more drawbacks than benefits. That does not mean the framework itself is bad, but it may be a big sledgehammer cracking a small nut. Your project has only two pages, so it is imaginable that making it without GWT is feasible.

Security of external jar file in GWT

I have created a GWT project which is successfully using an external jar file (see GWT - Using external jars / Java Projects by Lars Vogel‎ and Adding external jar in GWT).
When I use a library file like this, what happens when I compile the project and upload it to AppEngine? Does the jar file get uploaded as it is, or does it get compiled into something else first? And if the former, is it at any security risk of being downloaded without my control?
Let's drop the "google-app-engine" part, it doesn't matter here. You use the library in GWT, on client side. App Engine is server side, with no direct connection to GWT (but due to the volume restrictions it is quite useful to utilize some client side execution like GWT).
Everything you use in GWT will be compiled to JavaScript, transferred to the client and executed there. Obviously you have no control over the result and what the client does with it.
But it will be next to unreadable. Plus the client does not get the JAR per se and he does not get everything that is inside the JAR.
So what really matters is if the library's license allows this and if there are secrets in the library code that are only intended to be used on server side.
Actually, his's answer is not quite correct. The "google-app-engine"-part matters a lot here. Technically, GWT compiles and obfuscates all of the Java code it needs. And it strips out everything that it doesn't need. So, from the JavaScript generated by GWT, it should indeed be quite impossible to reconstruct or maybe even recognize the library. But it turns out that if you use the Eclipse plugin to deploy your app, appcfg uploads all sorts of random stuff to the AppEngine servers, sometimes including the entire Java source of the project (client side code included).
To see what exactly it uploads when you do a deploy, check in your system's temp-directory while the upload is running. You will find an AppEngine staging directory there that contains everything to be sent.
For suggestions for ways around this, you can refer to the answers to a question that I asked earlier: Removing unwanted uploads from AppEngine deployment
What I haven't checked is whether all the unwanted uploaded files end up in directories that are actually directly accessible from the internet.

My GAE python development datastore is never persisted to a file

I have just started using GAE (Python 2.7 SDK 1.6.4) , I have set up a
simple test project using Pydev (latest version) in eclipse (indigo)
on Windows XP (SP3).
It all works fine, my app can record data in the datastore and the blobstore
and then retrieve it, but when I stop the development server and start
it again the data in the datastore is lost. This is not the case for
the blobstore which is retaining blobs fine and I can see the
blobstore folder that gets created in C:\Temp
I did the sensible thing and look back through old posts and found
that most people who have this problem solve it by changing the
location of the datastore file, so I used the following parameters;
--datastore_path="${workspace_loc}/myproject/datastore"
--blobstore_path="${workspace_loc}/myproject/blobstore"
"${workspace_loc}/myproject/src"
I moved the blobstore at the same time as you can see.
The blobstore still works, and now the blobstore folder is created in
myproject folder as expected. The datastore file is still not created
however, and when I stop and restart the development server the data
is still lost.
The dev server startup logs include the following entry
WARNING 2012-04-20 10:49:04,513 datastore_file_stub.py:513] Could not
read datastore data from C:\myworkspace\myproject\datastore
So I know it is trying to create the datastore in the correct place.
Finally I lifted the whole eclipse workspace folder and copied it to
another computer with exactly the same setup except it is running
Windows 7 instead of Windows XP.
Everything works fine there - both the datastore file and blobstore
folder are now created where I expect them to be.
I have set up eclipse, python, gae, my project and my eclipse launch
file in exactly the same way on two computers, it works on one and
not the other. Maybe XP is something to do with it but to be honest I
think that's unlikely.
The only other clue I have come up with is that a recent change to the
GAE development server stopped writing to the datastore file after
every change and only flushes on exit, this problem may be closely related to mine;
App Engine local datastore content does not persist
However adding the following to my code did not help at all.
from google.appengine.tools import dev_appserver
import atexit
atexit.register(dev_appserver.TearDownStubs)
So it's not down to incorrect termination sequence either as far as I
can tell although it may be that I was just added it in the wrong place (I'm am new to python).
Anyway I am stumped and I would be really grateful for suggestions you
guys can come up with.
It's probably http://code.google.com/p/googleappengine/issues/detail?id=7244 and a bug. Hopefully a fix will be available soon.
did you try:
--storage_path=...
Path at which all local files (such as the Datastore, Blobstore files, Google Cloud Storage Files, logs, etc) will be stored, unless overridden by --datastore_path, --blobstore_path, --logs_path, etc.
found at https://developers.google.com/appengine/docs/python/tools/devserver?csw=1

Google App Engine access to code

Is it possible to access or download my code that is running on Google App Engine? For instance, say my hard drive crashes and I have not saved my code on any kind of external repository. Is there any way to recover?
No, it is not possible. You compile your code on your machine and ship up the compiled code.
If you have a source repository, always make sure that you have a backup.
GAE does not have a mechanism for you to download your binaries, so reverse engineering them is not possible except from your own copies.
Of course you could always host your project on GitHub or SourceForge
see also:
how to download google appengine (uploaded)application files
Can I restore my source code that has been uploaded into Google AppEngine?
How do I download the source code of a google app engine project?
Download source code of deployed GAE application
Get source of appengine published version
I can't find it now, but I remember reading a post where they were pretty specific about NOT being able to do that. The gist of it was that they were not a backup service and that you were responsible for backing up your own code.
There is a "datastore backup and restore" feature on the project roadmap though: http://code.google.com/appengine/docs/roadmap.html I've skimmed over a few posts where people talk about ways to backup the database now without that the official sanctioned feature implemented... of course your datastore isn't your code.

Google app engine to run executable files

Is it possible to run executable files in google app engine? Like by using Runtime.exec?
There is whitelist on google app engine documentation which list classes that can be used but functions/ inside the classes are not specified.
No, absolutely not.
The only thing that make AppEngine possible is that both the Python and Java environments are controlled by Google so that performance/scability and security issues are minimized. They don't even allow to use all the standard Java/Python classes, so imagine the problems that could arise if they let people run any executable file. One may even be a virus!

Resources