Sunday, May 16, 2010

App Engine People gets stats

mugurm:

Sebastian put up a statistics page up on appenginepeople.net. Check it out and see what version of the SDK devs are using and also what the countries with the most google app engine developers are.

Sunday, March 28, 2010

BlobStore upload with django form validation Example

This is my current approach to handle blobstore uploads that also need a django form validation.

You can find the get_uploads helper function here: blobstore get_uploads helper function for django request

I tried to do the example as simple as possible, but complete. This may not be perfect, all comments are welcome.

Seba


#### core/models.py ####

from google.appengine.ext import blobstore
from google.appengine.ext import db

class PhotoItem(db.Model):
    name = db.StringProperty()
    photo = blobstore.BlobReferenceProperty()

#### core/forms.py ####

from django import forms

class PhotoForm(forms.Form):
    name = forms.CharField(required=True)


##### core/views.py ####

from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext

from google.appengine.ext import blobstore

from core.models import PhotoItem
from core.forms import PhotoForm
from core.utils import get_uploads

def upload_photo(request):
    if request.method == 'POST':
        photo_blobs = get_uploads(request, field_name="photo", populate_post=True)
        form = PhotoForm(request.POST)
        if form.is_valid() and len(photo_blobs) == 1:
            photo_item = PhotoItem(name=form.cleaned_data['name'],
                                   photo=photo_blobs[0])
            photo_item.put()
            
            return HttpResponseRedirect("/success")
        
        #ok, not valid
        if len(photo_blobs) == 0:
            #the file input is missing
            request.session['upload_error'] = "Photo is required"
            
        #save the post data in the session to be able to present errors after redirect
        request.session['upload_form_post'] = request.POST
        return HttpResponseRedirect(reverse("core.views.upload_photo"))
    elif request.session.has_key('upload_form_post'):
        form = PhotoForm(request.session['upload_form_post'])
        del request.session['upload_form_post']
    else:
        form = PhotoForm()
    
    params = {
        'upload_url': blobstore.create_upload_url(reverse("core.views.upload_photo")),
        'form': form,
        'upload_error': request.session.pop('upload_error', None)
    }
    
    return render_to_response("upload_photo.html", 
                              params,
                              RequestContext(request))

#### Example upload_photo.html ####
{% extends "base.html" %}

{% block main_content %}
    <h1>Upload Photo</h1>
    
    {% if upload_error %}
    <div class="error">{{ upload_error }}</div>
    {% endif %}
    <form action="{{ upload_url }}" method="post" 
                  enctype="multipart/form-data">
    <ul>
        {{ form.as_ul }}
        <li><input type="file" name="photo"/></li>
        <li><input type="submit"/></li>
    </ul>
    </form>
{% endblock %}
Thursday, March 25, 2010
late snack

late snack

Tuesday, March 9, 2010

AppEngine Developer Directory

mugurm:

We’ve recently launched AppEnginePeople.net, a new directory site for Google App Engine developers, which is basically a clone of DjangoPeople.net but for app engine.

If you are interested in creating a profile just visit the site and sign in with your Google account.

Monday, March 8, 2010

appenginepeople

if you develop apps for #appengine you can add yourself to http://www.appenginepeople.net/

Wednesday, February 17, 2010
antibiotics for an awful cold

antibiotics for an awful cold

Sunday, December 20, 2009

tracking html5/css3 support with analytics and modernizr

You may think that html5 and css3 is going to become widespread in something akin to a geologic time scale. The truth is that many html5 and css3 features have currently widespread support.

Below, there is an small snippet to track the browser support for these advanced features for your user base, using google analytics and modernizr.

Modernizr is a small footprint javascript library that let you test the support of html5 and css3 features. With the combination of modernizr and analytics custom vars, we can track which percent of our users support a particular html5 or css3 feature.

So suppose we want to know the user base support for: sessionstorage, localstorage, canvas, fonfaces and borderradius.

Our analytics tracking code would look like:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? 
"https://ssl." : "http://www."); 
document.write(unescape("%3Cscript src='" + gaJsHost + 
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript" src="/media/js/modernizr-1.1.min.js"></script>
<script type="text/javascript">

try {
var pageTracker = _gat._getTracker("UA-YYYYY-X");

pageTracker._setCustomVar(1, "sessionstorage", Modernizr.sessionstorage , 2 );
pageTracker._setCustomVar(2, "localstorage", Modernizr.localstorage, 2 );
pageTracker._setCustomVar(3, "fontface", Modernizr.fontface, 2 );
pageTracker._setCustomVar(4, "canvas", Modernizr.canvas, 2 );
pageTracker._setCustomVar(5, "borderradius", Modernizr.borderradius, 2 );

pageTracker._trackPageview();

} catch(err) {}</script>

After you append this to your site html body the results are going to appear on analytics under “visitors > custom variables”

Using a similar snippet we found that at www.wegif.com more than 80% of our users support all these features. Cool right?

For more info about how all this works, continue reading at:

http://www.modernizr.com/

http://code.google.com/intl/en/apis/analytics/docs/tracking/gaTrackingCustomVariables.html

Thursday, December 17, 2009 Monday, December 7, 2009

appengine-storages has now a datastore backend

I just push a datastore based backend.

The code still needs more work and testing, so please not use it on any production site.

But if you are brave enough (or stupid) to do it, send me an email with your experience.

Cheers, Sebastián

Friday, November 27, 2009

django-flash works on app engine

The django-flash application, that provides a Rails-like flash messages support for Django. Works out of the box, if you have session support at the Google App Engine.

http://djangoflash.destaquenet.com/