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
Caveats: | |
- Calling put on a fetched entity more than once has extra overhead. | |
- Putting entities that have been concurrently modified since they were fetched has extra overhead even outside transactions. | |
- Creating and putting an entity to overwrite one already in the datastore has extra overhead. | |
- Attempting to create and put an entity in a transaction when one already exists in the datastore will fail. | |
- Strings are sorted by a 'smart' caseless sort rather than by unicode codepoint. | |
- Custom indexes with multiple sort orders are not supported. | |
- Does not (currently) support merge joins, so no support for multiple equality filters with no composite index. | |
Bonuses: |
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 logging | |
from google.appengine.api import memcache | |
from google.appengine.api import apiproxy_stub_map | |
from google.appengine.datastore import datastore_pb | |
"""Provides a shim that caches datastore Get calls. | |
Example code: | |
import datastore_get_cache |
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 math | |
def between(a, b, c): | |
return a <= b and b <= c | |
class Region(object): | |
def intersects(self, other): | |
raise NotImplemented( | |
"%s does not know how to check for intersection with %s" |
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
"""Modifies the App Engine datastore to support local caching of entities. | |
This is achieved by monkeypatching google.appengine.ext.db to recognise model | |
classes that should be cached and store them locally for the duration of a | |
single page request. | |
Note that only datastore gets (and anything that relies on them, such as | |
ReferenceProperty fetches) are cached; queries will neither return cached | |
entities nor update the cache. | |
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
#!/usr/bin/python | |
"""Converts Python packages into app-engine-friendly zips or directories.""" | |
import logging | |
import optparse | |
import os | |
import re | |
import sys | |
import zipfile | |
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 base | |
import config | |
import model | |
import simploid | |
import urllib | |
from openid.extensions import sreg | |
from google.appengine.ext.db import djangoforms | |
from django import newforms as forms | |
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 logging | |
import os | |
import StringIO | |
from google.appengine.ext import db | |
BLOCK_NAME_FMT = '#%.8X' | |
class Inode(db.Model): | |
DEFAULT_BLOCK_SIZE = 524288 | |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Module> | |
<ModulePrefs title="Members" | |
description="Awaken your community with the members gadget which lets visitors join your site, sign in, and invite their friends. They can even explore the profiles of other members and make new friends." | |
author="Google" | |
author_email="friendconnect-feedback+gadgets@google.com" | |
thumbnail="http://www.google.com/friendconnect/static/images/thumb/members.png" | |
screenshot="http://www.google.com/friendconnect/static/images/thumb/members.png" | |
> | |
<Require feature="dynamic-height"/> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Module> | |
<ModulePrefs title="Members" | |
description="Awaken your community with the members gadget which lets visitors join your site, sign in, and invite their friends. They can even explore the profiles of other members and make new friends." | |
author="Google" | |
author_email="friendconnect-feedback+gadgets@google.com" | |
thumbnail="http://www.google.com/friendconnect/static/images/thumb/members.png" | |
screenshot="http://www.google.com/friendconnect/static/images/thumb/members.png" | |
> | |
<Require feature="dynamic-height"/> |
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 logging | |
from google.appengine.ext import db | |
class KindIterator(object): | |
def __init__(self, kind, filters=None, batch_size=100): | |
self.kind = kind | |
if filters: | |
self.filters = filters | |
else: | |
self.filters = [] |
OlderNewer