Created
October 19, 2010 21:43
-
-
Save kamawanu/635194 to your computer and use it in GitHub Desktop.
bulk insert mixin, for google appengine
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/env python | |
#https://gist.github.com/635194 | |
import logging | |
from google.appengine.ext import db | |
__all__ = [ | |
"bulkinsert", | |
] | |
class bulkinsert(object): | |
bulkinsert_queue = [] | |
@classmethod | |
def _pending(cls1,data): | |
cls1.bulkinsert_queue.append(data) | |
logging.debug(cls1.bulkinsert_queue) | |
def pending(self): | |
self.__class__._pending(self) | |
@classmethod | |
def bulkinsert(cls1): | |
db.put( cls1.bulkinsert_queue ) | |
cls1.bulkinsert_queue = [] | |
@classmethod | |
def __len__(cls1): | |
return len(cls1.bulkinsert_queue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment