This is what I have so far:
def get_ad():
total_count = Ad.all().count()
all_Ads = Query(Ad).fetch(1000)
memcache.add("total_count_of_ads", total_count)
# assume total_ads to be less than 1000 for now
a_random_Ad = random.randint(0, total_count - 1)
my_random_Ad = all_Ads[a_random_Ad]
#print my_random_Ad.name
# if you are using Django templates, it can be passed to the HTMl
form as
template_values = dict()
template_values['ad_url'] = my_random_Ad.adurl
# and then pass this template values and render the template
# render_to_response(request, template, data, mimetype)
template_path = string.join(os.path.dirname(__file__).split('/')
[:-1], '/')+ '/templates/root.html'
t = get_template(template_path)
html = t.render(Context(template_values))
return html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---