Skip to content

Instantly share code, notes, and snippets.

@kamawanu
Created October 19, 2010 21:43
Show Gist options
  • Save kamawanu/635194 to your computer and use it in GitHub Desktop.
Save kamawanu/635194 to your computer and use it in GitHub Desktop.
bulk insert mixin, for google appengine
#!/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