Well ive been spending the last week and a bit with my first AppEngine project. I had recieved my account on the day it was released (yes a shameless boast there :D)… Unfortunately due to exams never got around to doing anything with it.
So as a simple project I figured Il write (yet another online) chess game – WizChess. Note that there is already a Blitz Chess as part of the appengine samples page. I wanted to write one just to get a feel for the engine and to largely to learn a lot of things myself. There are a still a few things I have not implemented (eg on a castle, the server updates, but the client does not properly update UI. en-passante-s are not implemented. Timed game not hapening yet, chatting between players not yet happening and so on).
It was a very interesting experience. The documentation was quite nice and full, but still I was not fully satisfied. For some reason I found django a lot more satisfying as a web-app dev platform. For the models for the game I had chosen to follow a more django style (relational) rather than harnessing the rich model extensions provided by appengine (mainly the Expando Models). I had done this as I wasnt sure if I wanted to seal my app purely to the AppEngine platform. And after finishing the project, I am still not sure that I do.
I had got a whole bunch of puzzle games from here. Now I had needed a way to update the database with an initial data set. So my way was to have a url on the webapp (something like /resetdb) that would load the initial board templates (and in the future games that are saved and so on). However, since this loading would take some time, I had to resort to breaking this up into several parts and calling each of these individually. eg: Id nomally have:
class ResetDB(webapp.RequestHandler): def get(self): for board in my_boards: add_board_to_db(board)
Now as the number boards in my data set increased, the time to put them in the data store would naturally increase. But there seems to a time limit on each request, which would make my request fail. So I had to resort to writing a client side script that would call ResetDB with parameters (eg, firstboard and lastboard) and then also break em up as more saved games were restored etc. Absolute Pain! Its all good for appengine to be smart about things but to impose assumptions severely limits the usefulness of this platform and I hope in the future this is released.
Next thing was the model apis. The Expando model is awesome, but once again I was not happy about the lockin. But this was not my main concern. The querying api is extremely poor. Django has amazing querying facilities where one can specify pretty much arbitrary query filters (not a and c or a minus x and so on). AppEngine does not support “not”s in its query. Aaaaaaaaaaaaaaaaah. Also I couldnt find an easy way of chaining queries. Eg, to find a game, where either player0 or player1 (my way of saying white or black) was user, I had to do this:
games_with_user =  games = models.Game.all() games_with_user.extend([g for g in games if g['player0'] = current_user]) games_with_user.extend([g for g in games if g['player1'] = current_user])
Yuck! Same thing in Django happens with:
games_with_user = models.Game.filter(Q(player0 = current_user) or Q(player1 = current_user))
(ok I did that syntax from memory so it may not be right, but it is something similar).
Now the final that REALLY annoyed me was lack of Comet (or any reverse ajax) support. Essentially I poll the server every 5 seconds to get updates on whether the opponent has played. Would have been great for the server to notify the client instead of having to keep polling and waste requests (I believe there is a limit of 6.5 million requests a day or is that 650K requests?)
But having said all this, the main (only?) advantage of the platform is the fact that we dont have to worry about scalability. Unfortunately this is a HUGE advantage. Normally I could write an app, and host it on my own boxes at home (if i want it to be free), but then il soon be hitting limits with 10 users and Il have to find a hoster and also handle scalability issues myself. So migrating my own code to appengine at THAT point would be quite a nightmare. By writing and prototyping it on appengine allows me to fail fast. Looking at the pricing, app engine would charge about $40 per month per app (with reasonable traffic). If my app ever got to that stage, I could always port it out of appengine (as long as I dont use Expando and stick to django style object modelling – with which I dont loose any power).
Please let me know if you would like the sources. I am not sure how to upload files to wordpress here.
Also I would really appreciate it if you could give me feedback on my learning here. As a python and web-app noob, Id be grateful for pointing any errors in my ways 😀