# Path: gogogo/models/cache.py
# def getCachedEntityOr404(model = None,key=None,key_name=None , id = None , id_or_name = None):
# 	"""
# 	Get cached entity object generated by createEntity()
# 	"""
# 	
# 	if id_or_name:
# 		try:
# 			id = int(id_or_name)
# 		except ValueError:
# 			key_name = id_or_name	
# 	
# 	cache_key = getCacheEntityKey(model = model ,key=key , key_name = key_name, id = id)
# 	
# 	entity = memcache.get(cache_key)
# 
# 	if entity == None:
# 		object = getCachedObjectOr404(model, key=key,key_name=key_name, id = id)
# 		entity = createEntity(object)		
# 		
# 		if not memcache.add(cache_key, entity, _default_cache_time):
# 			logging.error("Memcache set %s failed." % cache_key)
# 	
# 	return entity


from django.http import HttpResponse
from django.http import Http404
from django.template import Context, loader , RequestContext
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.forms import ModelForm
from ragendja.auth.decorators import staff_only
from ragendja.template import render_to_response
from gogogo.models import *
from django.core.urlresolvers import reverse
from gogogo.models.cache import getCachedEntityOr404
from google.appengine.api import memcache

    if cache == None:
        query = Agency.all(keys_only=True)
	
        result = []
        for key in query:
            entity = getCachedEntityOr404(Agency,key = key)
            result.append(trEntity(entity,request))

        cache = {}
        cache['result'] = result
        memcache.add(cache_key, cache, _default_cache_time)
        
    agency_list = cache['result']
           
    t = loader.get_template('gogogo/db/agency/list.html')
    c = RequestContext(
        request,
    {
        'page_title': _("Agency List"),
        'agency_list' : agency_list
    })
            
    return HttpResponse(t.render(c))

def browse(request,id):
    """
    Browse the information of an agency
    """


# Path: gogogo/models/cache.py
# def getCachedEntityOr404(model = None,key=None,key_name=None , id = None , id_or_name = None):
# 	"""
# 	Get cached entity object generated by createEntity()
# 	"""
# 	
# 	if id_or_name:
# 		try:
# 			id = int(id_or_name)
# 		except ValueError:
# 			key_name = id_or_name	
# 	
# 	cache_key = getCacheEntityKey(model = model ,key=key , key_name = key_name, id = id)
# 	
# 	entity = memcache.get(cache_key)
# 
# 	if entity == None:
# 		object = getCachedObjectOr404(model, key=key,key_name=key_name, id = id)
# 		entity = createEntity(object)		
# 		
# 		if not memcache.add(cache_key, entity, _default_cache_time):
# 			logging.error("Memcache set %s failed." % cache_key)
# 	
# 	return entity


# Path: gogogo/views/db/agency.py
from django.http import HttpResponse
from django.http import Http404
from django.template import Context, loader , RequestContext
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.forms import ModelForm
from ragendja.auth.decorators import staff_only
from ragendja.template import render_to_response
from gogogo.models import *
from django.core.urlresolvers import reverse
from gogogo.models.cache import getCachedEntityOr404
from google.appengine.api import memcache


    if cache == None:
        query = Agency.all(keys_only=True)
	
        result = []
        for key in query:
            entity = getCachedEntityOr404(Agency,key = key)
            result.append(trEntity(entity,request))

        cache = {}
        cache['result'] = result
        memcache.add(cache_key, cache, _default_cache_time)
        
    agency_list = cache['result']
           
    t = loader.get_template('gogogo/db/agency/list.html')
    c = RequestContext(
        request,
    {
        'page_title': _("Agency List"),
        'agency_list' : agency_list
    })
            
    return HttpResponse(t.render(c))

def browse(request,id):
    """
    Browse the information of an agency
    """


    agency = getCachedEntityOr404(Agency,id_or_name=id)