Progress II: update sqlalchemy pithos backend lib
[pithos] / snf-pithos-backend / pithos / backends / lib / sqlalchemy / public.py
index d7ae0f2..bb06282 100644 (file)
@@ -74,10 +74,17 @@ class Public(DBWorker):
         r = self.conn.execute(s)
         r.close()
     
+    def public_unset_bulk(self, paths):
+        s = self.public.update()
+        s = s.where(self.public.c.path.in_(paths))
+        s = s.values(active=False)
+        r = self.conn.execute(s)
+        r.close()
+    
     def public_get(self, path):
         s = select([self.public.c.public_id])
         s = s.where(and_(self.public.c.path == path,
-                                        self.public.c.active == True))
+                         self.public.c.active == True))
         r = self.conn.execute(s)
         row = r.fetchone()
         r.close()
@@ -85,10 +92,19 @@ class Public(DBWorker):
             return row[0]
         return None
     
+    def public_list(self, prefix):
+        s = select([self.public.c.path, self.public.c.public_id])
+        s = s.where(self.public.c.path.like(self.escape_like(prefix) + '%', escape='\\'))
+        s = s.where(self.public.c.active == True)
+        r = self.conn.execute(s)
+        rows = r.fetchall()
+        r.close()
+        return rows
+    
     def public_path(self, public):
         s = select([self.public.c.path])
         s = s.where(and_(self.public.c.public_id == public,
-                                        self.public.c.active == True))
+                         self.public.c.active == True))
         r = self.conn.execute(s)
         row = r.fetchone()
         r.close()