Spycify them all!

Recently I've launched my first site, that was revealed to some friends whose critisism I'm not afraid of :). It is called Spycify, and was made just for fun using Python, Google App Engine and some outside APIs.

Actually I saw facedetection API on Programmable Web, and decided that I should do something with it. There was no doubt on selecting programming language. It is Python for sure. As a hosting/framework I've chosen Google App Engine. I see it as a free place for little experiments. I know my service wouldn't need any highscalability, performancability or other cool-abilities. This is just a good place to host a little project, fast to code, fast to deploy. I know that if I place my service on GAE it will be there forever some forseeable future, so I can come back to it, if I want to and show it. There's no need to think about hosting, domain name or something like this - it "just works".

Of course using GAE puts some restrictions and makes you do something in quite wierd way. I'll try to tell about places that made me scratch my nape to think why did Google did it and how to deal with it.

File upload handler. That was one of my first surprises - you need to get special url for POST request from GAE to upload file (see blobstore.create_upload_url()). I have no experience anywhere else, but I can't understand why do I need to do it. At first I placed this call to my view function, that responses with a photo upload page. But soon I realized this is a bad place for it if I want my users to upload more then one photo. The fastest and most obvious way to return on previous page is Back browser button. But because cached page was returned with old, "used" upload url, which you can't use (server raises exception). So I need to update it every time user visits a page. I ended up creating special handler, that only does return of new upload url and requested it in jQuery's ready(). Something like:

   $.get('/upload_url', function(data) {
      $('div.upload-form > form')[0].action = data });

See topic on this issue at tipfy (GAE framework) mailing list for more.

GAE image and blob handling inconsistancy. There are two kinds of model fields for blob-values. One of them is BlobInfo, which is given to you when you process uploaded files. More for that, it is a datastore object itself, so you can get it from the store by key and (most interesting for me) use Picasa infrastructure to serve such images to user. BUT you can't create it manually - it is made only by GAE with uploaded files.

Other field is plain BlobProperty, which only holds a byte-string of something. The main problem is that if you mant somehow modify content of uploaded file and then save it, you can do it only in a plain BlobProperty, no BlobInfo object, no cool, fast, efficient Picasa resources to show your pics. Only reading them from datastore and serving them with an ugly view.

That's all, basically. I'm using web.py + django templates, a which are in a box with GAE. I didn't try to use django ports to GAE, because I don't need them for such small project.

I still have many things to polish and to clean. I'd like to add sharing not only to vkontakte, but to facebook and buzz. But it is already usable. So please, go try it and please tell me what you think about it!

No comments:

Post a Comment

Thanks for your comment!
Come back and check response later.