I was trying to do something simple - get a preloaded partial from the server via ajax. my api call worked directly in the browser, worked when I ran it with $.get() from the console after the page was loaded, but was returning 500 during page load (as in, only failing when it was called as js running at after dom load). I could confirm that the correct flask view was running and succeeding using logging, but the 500 I was getting had NO responsetext, and nothing useful..
After fighting and fruitless searching for 40 minutes, I disabled the flask debug toolbar. Voila! everything worked as expected.
Moral of the story: F$@# the flask debug toolbar.
facepalms: 8
Showing posts with label app engine. Show all posts
Showing posts with label app engine. Show all posts
Wednesday, February 18, 2015
Wednesday, February 22, 2012
app engine and appcfg import errors
If you get an error that looks like the below, be sure that you are importing the correct version of django(which is to say, that if you are using the builtin version, be sure you are not also importing another version of django from your sitepackages). Appcfg automatically follows all symlinks and packages up everything on your pythonpath, and the import order in production is different (actually reversed!) from that in development.
I solved this problem by deactivating my virtualenv whenever I deploy.
facepalms: 8 (3 hours of nonsense for a 1-line fix!)
Labels:
app engine,
django,
python,
virtualenv,
virtualenvwrapper
app engine and datastore keys
say you know the key name's string of a Model instance and you want to fetch it from the datastore. It goes like this:
Model.get(db.Key.from_path("Model",key_name))
why so complicated? why can't you just Model.get(key_name)? Couldn't tell you, but was getting inexplicable errors that way.
facepalms: 4
Tuesday, February 14, 2012
Porting Postgres to google cloud SQL
I know it's quite a peculiar problem - you have a postgres database, and suddenly you're migrating to Google App Engine and you want to use the new Google Cloud SQL (look it up, it's public and it's pretty cool).
Anyway, you need to port the old data. Google cloud sql is cool except for a big problem - sql dump imports have 0 error reporting - if it fails, it just turns red and tells you that an unknown error occurred. So here's how I made it work:
- dump the postgres stuff selecting the tables you want with a couple extra options on:
- pg_dump --column-inserts --data-only POSTGRES_DATABASE_NAME -t TABLE_NAME -t ANOTHER_TABLE_NAME -f NEW_FILE_NAME.sql [note: you need to have psql privileges already here].
- delete the top lines of the dump file created in 2) until the first "insert" line.
- load it into mysql locally, where you can catch any errors:
- mysql -u USER -p DATABASE_NAME < NEW_FILE_NAME
- dump it from the local mysql:
- mysqldump -u USERNAME -p --add-drop-table MYSQL_DATABASE_NAME TABLE_NAME ANOTHER TABLE_NAME> FIXED_SQL_DUMP_FILE.sql
- add as the first line in the new dumpfile: "use DATABASE_NAME;" (ignore the quotes, add the name of the database you want the data loaded into on google).
- Now you can load this new file into a google cloud storage bucket using their web browser gui and from there import it into cloud sql.
- pray, as you wait for the stupid thing with no error reporting to turn green.
facepalms: 7
Labels:
app engine,
cloud sql,
databases,
django,
google cloud sql,
mysql,
postgres
Thursday, February 9, 2012
app engine and django mail
lo and behold, local email (as in, sending email to console) in django works with the app engine development server, but not with the app engine development backend / taskqueue server. It gives you an attributeerror: Exception Value: 'module' object has no attribute 'getfqdn'
Subscribe to:
Posts (Atom)