Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: third_party/twisted_8_1/twisted/persisted/journal/rowjournal.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/twisted_8_1/twisted/persisted/journal/rowjournal.py
diff --git a/third_party/twisted_8_1/twisted/persisted/journal/rowjournal.py b/third_party/twisted_8_1/twisted/persisted/journal/rowjournal.py
deleted file mode 100644
index 0246222d6b086c4081f10f811c79306acc311754..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/persisted/journal/rowjournal.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-#
-
-"""Journal using twisted.enterprise.row RDBMS support.
-
-You're going to need the following table in your database::
-
- | CREATE TABLE journalinfo
- | (
- | commandIndex int
- | );
- | INSERT INTO journalinfo VALUES (0);
-
-"""
-
-from __future__ import nested_scopes
-
-# twisted imports
-from twisted.internet import defer
-
-# sibling imports
-import base
-
-
-# constants for command list
-INSERT, DELETE, UPDATE = range(3)
-
-
-class RowJournal(base.Journal):
- """Journal that stores data 'snapshot' in using twisted.enterprise.row.
-
- Use this as the reflector instead of the original reflector.
-
- It may block on creation, if it has to run recovery.
- """
-
- def __init__(self, log, journaledService, reflector):
- self.reflector = reflector
- self.commands = []
- self.syncing = 0
- base.Journal.__init__(self, log, journaledService)
-
- def updateRow(self, obj):
- """Mark on object for updating when sync()ing."""
- self.commands.append((UPDATE, obj))
-
- def insertRow(self, obj):
- """Mark on object for inserting when sync()ing."""
- self.commands.append((INSERT, obj))
-
- def deleteRow(self, obj):
- """Mark on object for deleting when sync()ing."""
- self.commands.append((DELETE, obj))
-
- def loadObjectsFrom(self, tableName, parentRow=None, data=None, whereClause=None, forceChildren=0):
- """Flush all objects to the database and then load objects."""
- d = self.sync()
- d.addCallback(lambda result: self.reflector.loadObjectsFrom(
- tableName, parentRow=parentRow, data=data, whereClause=whereClause,
- forceChildren=forceChildren))
- return d
-
- def sync(self):
- """Commit changes to database."""
- if self.syncing:
- raise ValueError, "sync already in progress"
- comandMap = {INSERT : self.reflector.insertRowSQL,
- UPDATE : self.reflector.updateRowSQL,
- DELETE : self.reflector.deleteRowSQL}
- sqlCommands = []
- for kind, obj in self.commands:
- sqlCommands.append(comandMap[kind](obj))
- self.commands = []
- if sqlCommands:
- self.syncing = 1
- d = self.reflector.dbpool.runInteraction(self._sync, self.latestIndex, sqlCommands)
- d.addCallback(self._syncDone)
- return d
- else:
- return defer.succeed(1)
-
- def _sync(self, txn, index, commands):
- """Do the actual database synchronization."""
- for c in commands:
- txn.execute(c)
- txn.update("UPDATE journalinfo SET commandIndex = %d" % index)
-
- def _syncDone(self, result):
- self.syncing = 0
- return result
-
- def getLastSnapshot(self):
- """Return command index of last snapshot."""
- conn = self.reflector.dbpool.connect()
- cursor = conn.cursor()
- cursor.execute("SELECT commandIndex FROM journalinfo")
- return cursor.fetchall()[0][0]
« no previous file with comments | « third_party/twisted_8_1/twisted/persisted/journal/picklelog.py ('k') | third_party/twisted_8_1/twisted/persisted/marmalade.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698