GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Showing posts with label GAE. Show all posts
Showing posts with label GAE. Show all posts

Tuesday, May 10, 2011

GAE - Template

Introduction

Template makes your life easier. it separating between code logic of your program to what should display on the browser. Here's I just show up what the crucial template case that not handled by Django documentation.

Displaying List of Articles

It's really some often occurance for us to display item list. It's like blog post that consits of title, date, and content. Or it like personal data that consists of name, email, address and more. Here's for example we has some blog post:

Data Content

TitleContent
GAE TemplateGAE Template is use Django template system. So when you are accustomed for using Django, it's good for you.
GAE RuntimeThere are two available runtime for you. The first is Java and the second is Python. Whatever you choose, it should based on your preference for the language and your current skills.
GAE DatastoreIn GAE, your data is saved in database, but you never handle it directly, because Google Datastore that handles it, and in all your time, you handle the datastore. The operation for data in datastore is like in native sql, but it's more abstract than it that is called GQL - Google Query Language.
For example you want to display the data on the home page, what you need is you main the logic code that retrieves the data using Google datastore query.

Program code: main.py

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template

class Blog(db.Model):     title = db.StringProperty()
    content = db.TextProperty()

class MainPage(webapp.RequestHandler):
    blog = Blog()
    query = db.GqlQuery("SELECT * FROM Blog")
    data = []
    for row in query:
        mapp = {}
        mapp['title'] = row.title
        mapp['content'] = row.content
        data.append(mapp)


Share/Bookmark

GAE - Introduction

Introduction

Google App Engine is the platform for building web application. There's a built-in framework and already hosting servince provided by Google. The application environtment is two: Java and Python. Whenever you choose one, it's up to you.

How To

To starting development, you can download it first from code.google.com. Here we use Python version environment. After finishing for downloading, please install it.

The first is create directory, named "Hello" in whatever you want to place it - for example in "D:\\Hello". The second, is create two files: app.yaml and main.py, and then write this code.


Share/Bookmark