This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext import db | |
class ChoiceProperty(db.IntegerProperty): | |
"""A property for efficiently storing choices made from a finite set. | |
This works by mapping each choice to an integer. The choices must be hashable | |
(so that they can be efficiently mapped back to their corresponding index). | |
Example usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from http://appengine-cookbook.appspot.com/recipe/lazy-loading-webapp-handler/ | |
def _istring(import_name): | |
"""Imports an object based on a string. | |
@param import_name the dotted name for the object to import. | |
@return imported object | |
""" | |
module, obj = import_name.rsplit('.', 1) | |
# __import__ can't handle unicode strings in fromlist if module is a package | |
if isinstance(obj, unicode): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: dummy-for-nose-gae | |
version: test | |
runtime: python | |
api_version: 1 | |
handlers: | |
- url: /.* | |
script: request.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implements a request handler which caches the response to GET requests. | |
Big Picture: | |
* memcache is used to cache generated content. | |
* Task queue is used to regenerate the content when it expires. | |
* When a page expires, the old page is continued to be served until the new | |
page is ready (to minimize downtime). | |
* A new page will be generated only if the old page has expired AND someone is | |
requesting the page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Created by David Underhill (http://www.dound.com) -- You are free to use/modify this code however you like. */ | |
var countryOptions='<option value="AU">Australia</option><option value="CA">Canada</option><option value="IE">Ireland</option><option value="UK">United Kingdom</option><option value="US" selected>United States</option><option value="??">Other</option>';var statesByCountry={"??":[["??","Other"]],AU:[["ACT","Australian Capital Territory"],["NSW","New South Wales"],["NT","Northern Territory"],["QLD","Queensland"],["SA","South Australia"],["TAS","Tasmania"],["VIC","Victoria"],["WA","Western Australia"]],CA:[["AB","Alberta"],["BC","British Columbia"],["MB","Manitoba"],["NB","New Brunswick"],["NL","Newfoundland and Labrador"],["NS","Nova Scotia"],["NT","Northwest Territories"],["NU","Nunavut"],["ON","Ontario"],["PE","Prince Edward Island"],["QC","Quebec"],["SK","Saskatchewan"],["YT","Yukon Territory"]],IE:[["CAR","Carlow"],["CAV","Cavan"],["CLA","Clare"],["COR","Cork"],["DON","Donegal"],["DUB","Dublin"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: yourappid | |
version: testgaesessions | |
runtime: python | |
api_version: 1 | |
handlers: | |
- url: /stats.* | |
script: $PYTHON_LIB/google/appengine/ext/appstats/ui.py | |
- url: /.* | |
script: main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, urllib | |
class RecaptchaResponse(object): | |
def __init__(self, is_valid, error_code=None): | |
self.is_valid = is_valid | |
self.error_code = error_code | |
def submit (recaptcha_challenge_field, | |
recaptcha_response_field, | |
private_key, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this file is from the google-chartwrapper project (http://code.google.com/p/google-chartwrapper/) | |
coding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | |
ecoding = coding + '-.' | |
codeset = { | |
'simple': { | |
'coding': coding, | |
'max_value': 61, | |
'char': ',', | |
'dchar': '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2010 David Underhill [email protected] | |
# This module is released under the MIT license: | |
# http://www.opensource.org/licenses/mit-license.php | |
""" | |
This module provides a wrapper around the urlfetch API which maximizes the | |
concurrency of asynchronous urlfetch requests (within app engine limits). | |
To start asynchronous fetch(es), first create an AsyncURLFetchManager and then | |
call call fetch_asynchronously() as many times as needed. For optimal | |
performance, start the fetches which are fastest first. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upsert(db_cur, table, pk_fields, schema=None, **kwargs): | |
"""Updates the specified relation with the key-value pairs in kwargs if a | |
row matching the primary key value(s) already exists. Otherwise, a new row | |
is inserted. Returns True if a new row was inserted. | |
schema the schema to use, if any (not sanitized) | |
table the table to use (not sanitized) | |
pk_fields tuple of field names which are part of the primary key | |
kwargs all key-value pairs which should be set in the row | |
""" |
OlderNewer