commit cb787cc4b485c04ebe09700851e4a4242d047540
Author: Sofia Papagiannaki <papagian@gmail.com>
Date:   Tue Sep 11 15:50:21 2012 +0300

    Change QuotaholderSync to QuotaholderSerial

diff --git a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/__init__.py b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/__init__.py
index ef73907..20b38d6 100644
--- a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/__init__.py
+++ b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/__init__.py
@@ -35,8 +35,8 @@ from dbwrapper import DBWrapper
 from node import Node, ROOTNODE, SERIAL, HASH, SIZE, TYPE, MTIME, MUSER, UUID, CHECKSUM, CLUSTER, MATCH_PREFIX, MATCH_EXACT
 from permissions import Permissions, READ, WRITE
 from config import Config
-from quotaholder_sync import QuotaholderSync
+from quotaholder_serials import QuotaholderSerial
 
 __all__ = ["DBWrapper",
            "Node", "ROOTNODE", "SERIAL", "HASH", "SIZE", "TYPE", "MTIME", "MUSER", "UUID", "CHECKSUM", "CLUSTER", "MATCH_PREFIX", "MATCH_EXACT",
-           "Permissions", "READ", "WRITE", "Config", "QuotaholderSync"]
+           "Permissions", "READ", "WRITE", "Config", "QuotaholderSerial"]
diff --git a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/quotaholder_serials.py b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/quotaholder_serials.py
new file mode 100644
index 0000000..b952781
--- /dev/null
+++ b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/quotaholder_serials.py
@@ -0,0 +1,81 @@
+# Copyright 2011-2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+from sqlalchemy import Table, Column, MetaData
+from sqlalchemy.types import BigInteger
+from sqlalchemy.sql import select
+from sqlalchemy.exc import NoSuchTableError
+
+from dbworker import DBWorker
+
+def create_tables(engine):
+    metadata = MetaData()
+    columns = []
+    columns.append(Column('serial', BigInteger, primary_key=True))
+    config = Table('qh_sync', metadata, *columns, mysql_engine='InnoDB')
+    
+    metadata.create_all(engine)
+    return metadata.sorted_tables
+
+class QuotaholderSerial(DBWorker):
+    """QuotaholderSerial keeps track of quota holder serials.
+    """
+
+    def __init__(self, **params):
+        DBWorker.__init__(self, **params)
+        try:
+            metadata = MetaData(self.engine)
+            self.qh_sync = Table('qh_sync', metadata, autoload=True)
+        except NoSuchTableError:
+            tables = create_tables(self.engine)
+            map(lambda t: self.__setattr__(t.name, t), tables)
+
+    def get_lower(self, serial):
+        """Return entries lower than serial."""
+
+        s = select([self.qh_sync.c.serial])
+        s = s.where(self.qh_sync.c.serial < serial)
+        r = self.conn.execute(s)
+        rows = r.fetchall()
+        r.close()
+        return rows
+    
+    def insert_serial(self, serial):
+        """Insert a serial.
+        """
+
+        s = self.qh_sync.insert()
+        r = self.conn.execute(s, serial=serial)
+        inserted_primary_key = r.inserted_primary_key[0]
+        r.close()
+        return inserted_primary_key
\ No newline at end of file
diff --git a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/quotaholder_sync.py b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/quotaholder_sync.py
deleted file mode 100644
index 0c46f52..0000000
--- a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/quotaholder_sync.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# Copyright 2011-2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from sqlalchemy import Table, Column, MetaData
-from sqlalchemy.types import BigInteger
-from sqlalchemy.sql import select
-from sqlalchemy.exc import NoSuchTableError
-
-from dbworker import DBWorker
-
-def create_tables(engine):
-    metadata = MetaData()
-    columns = []
-    columns.append(Column('serial', BigInteger, primary_key=True))
-    config = Table('qh_sync', metadata, *columns, mysql_engine='InnoDB')
-    
-    metadata.create_all(engine)
-    return metadata.sorted_tables
-
-class QuotaholderSync(DBWorker):
-    """QuotaholderSync are entries for syncing with quota holder.
-    """
-
-    def __init__(self, **params):
-        DBWorker.__init__(self, **params)
-        try:
-            metadata = MetaData(self.engine)
-            self.qh_sync = Table('qh_sync', metadata, autoload=True)
-        except NoSuchTableError:
-            tables = create_tables(self.engine)
-            map(lambda t: self.__setattr__(t.name, t), tables)
-
-    def get_lower(self, serial):
-        """Return entries lower than serial."""
-
-        s = select([self.qh_sync.c.serial])
-        s = s.where(self.qh_sync.c.serial < serial)
-        r = self.conn.execute(s)
-        rows = r.fetchall()
-        r.close()
-        return rows
-    
-    def insert_serial(self, serial):
-        """Insert a serial.
-        """
-
-        s = self.qh_sync.insert()
-        r = self.conn.execute(s, serial=serial)
-        inserted_primary_key = r.inserted_primary_key[0]
-        r.close()
-        return inserted_primary_key
\ No newline at end of file
diff --git a/snf-pithos-backend/pithos/backends/lib/sqlite/__init__.py b/snf-pithos-backend/pithos/backends/lib/sqlite/__init__.py
index 04201c2..67516e6 100644
--- a/snf-pithos-backend/pithos/backends/lib/sqlite/__init__.py
+++ b/snf-pithos-backend/pithos/backends/lib/sqlite/__init__.py
@@ -35,8 +35,8 @@ from dbwrapper import DBWrapper
 from node import Node, ROOTNODE, SERIAL, HASH, SIZE, TYPE, MTIME, MUSER, UUID, CHECKSUM, CLUSTER, MATCH_PREFIX, MATCH_EXACT
 from permissions import Permissions, READ, WRITE
 from config import Config
-from quotaholder_sync import QuotaholderSync
+from quotaholder_serials import QuotaholderSerial
 
 __all__ = ["DBWrapper",
            "Node", "ROOTNODE", "SERIAL", "HASH", "SIZE", "TYPE", "MTIME", "MUSER", "UUID", "CHECKSUM", "CLUSTER", "MATCH_PREFIX", "MATCH_EXACT",
-           "Permissions", "READ", "WRITE", "Config", "QuotaholderSync"]
\ No newline at end of file
+           "Permissions", "READ", "WRITE", "Config", "QuotaholderSerial"]
\ No newline at end of file
diff --git a/snf-pithos-backend/pithos/backends/lib/sqlite/quotaholder_serials.py b/snf-pithos-backend/pithos/backends/lib/sqlite/quotaholder_serials.py
new file mode 100644
index 0000000..68ccf68
--- /dev/null
+++ b/snf-pithos-backend/pithos/backends/lib/sqlite/quotaholder_serials.py
@@ -0,0 +1,60 @@
+# Copyright 2011-2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+from dbworker import DBWorker
+
+class QuotaholderSerial(DBWorker):
+    """QuotaholderSerial keeps track of quota holder serials.
+    """
+
+    def __init__(self, **params):
+        DBWorker.__init__(self, **params)
+        execute = self.execute
+
+        execute(""" create table if not exists qh_sync
+                          ( serial bigint primary key) """)
+    
+    def get_lower(self, serial):
+        """Return entries lower than serial."""
+
+        q = "select serial from qh_sync where serial < ?"
+        self.execute(q, (serial,))
+        return self.fetchall()
+    
+    def insert_serial(self, serial):
+        """Insert a serial.
+        """
+
+        q = "insert or ignore into qh_sync (serial) values (?)"
+        return self.execute(q, (serial,)).lastrowid
+        
\ No newline at end of file
diff --git a/snf-pithos-backend/pithos/backends/lib/sqlite/quotaholder_sync.py b/snf-pithos-backend/pithos/backends/lib/sqlite/quotaholder_sync.py
deleted file mode 100644
index e1bc4a1..0000000
--- a/snf-pithos-backend/pithos/backends/lib/sqlite/quotaholder_sync.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2011-2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from dbworker import DBWorker
-
-
-class Public(DBWorker):
-    """Paths can be marked as public."""
-
-    def __init__(self, **params):
-        DBWorker.__init__(self, **params)
-        execute = self.execute
-
-        execute(""" create table if not exists public
-                          ( public_id integer primary key autoincrement,
-                            path      text not null,
-                            active    boolean not null default 1 ) """)
-        execute(""" create unique index if not exists idx_public_path
-                    on public(path) """)
-
-    def public_set(self, path):
-        q = "insert or ignore into public (path) values (?)"
-        self.execute(q, (path,))
-        q = "update public set active = 1 where path = ?"
-        self.execute(q, (path,))
-
-    def public_unset(self, path):
-        q = "update public set active = 0 where path = ?"
-        self.execute(q, (path,))
-
-    def public_unset_bulk(self, paths):
-        placeholders = ','.join('?' for path in paths)
-        q = "update public set active = 0 where path in (%s)" % placeholders
-        self.execute(q, paths)
-
-    def public_get(self, path):
-        q = "select public_id from public where path = ? and active = 1"
-        self.execute(q, (path,))
-        row = self.fetchone()
-        if row:
-            return row[0]
-        return None
-
-    def public_list(self, prefix):
-        q = "select path, public_id from public where path like ? escape '\\' and active = 1"
-        self.execute(q, (self.escape_like(prefix) + '%',))
-        return self.fetchall()
-
-    def public_path(self, public):
-        q = "select path from public where public_id = ? and active = 1"
-        self.execute(q, (public,))
-        row = self.fetchone()
-        if row:
-            return row[0]
-        return None
-
-class QuotaholderSync(DBWorker):
-    """QuotaholderSync are entries for syncing with quota holder.
-    """
-
-    def __init__(self, **params):
-        DBWorker.__init__(self, **params)
-        execute = self.execute
-
-        execute(""" create table if not exists qh_sync
-                          ( serial bigint primary key) """)
-    
-    def get_lower(self, serial):
-        """Return entries lower than serial."""
-
-        q = "select serial from qh_sync where serial < ?"
-        self.execute(q, (serial,))
-        return self.fetchall()
-    
-    def insert_serial(self, serial):
-        """Insert a serial.
-        """
-
-        q = "insert or ignore into qh_sync (serial) values (?)"
-        return self.execute(q, (serial,)).lastrowid
-        
\ No newline at end of file
diff --git a/snf-pithos-backend/pithos/backends/modular.py b/snf-pithos-backend/pithos/backends/modular.py
index d8a2455..8d4899c 100644
--- a/snf-pithos-backend/pithos/backends/modular.py
+++ b/snf-pithos-backend/pithos/backends/modular.py
@@ -154,7 +154,7 @@ class ModularBackend(BaseBackend):
         params = {'wrapper': self.wrapper}
         self.permissions = self.db_module.Permissions(**params)
         self.config = self.db_module.Config(**params)
-        self.quotaholder_sync = self.db_module.QuotaholderSync(**params)
+        self.quotaholder_serials = self.db_module.QuotaholderSerial(**params)
         for x in ['READ', 'WRITE']:
             setattr(self, x, getattr(self.db_module, x))
         self.node = self.db_module.Node(**params)
