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 partialize(phrase, shortest=5): | |
"""Tokenize the string `phrase` argument for all possible sub-strings | |
at least `shortest` length of characters. | |
This is a work-around for Google App Engine's Search API not supporting | |
partial full-text search (as of time of writing, April 2013 | |
In case of BBCode-formatted phrase, you should first strip() away all | |
BBCode tags before passing the string to this method. |
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 datetime | |
from google.appengine.ext import ndb | |
# eventually import custom User class here and adjust paths below | |
# parameter in timedelta() assumes that tokens expire ~3 months after creation: | |
expiredTokens = User.token_model.query(User.token_model.created <= (datetime.datetime.utcnow() - datetime.timedelta(3*365/12))) | |
# delete the tokens in bulks of 100: | |
while expiredTokens.count() > 0: | |
keys = expiredTokens.fetch(100, keys_only=True) |