Revision af75e8a5 pithos/backends/lib/sqlite/public.py

b/pithos/backends/lib/sqlite/public.py
43 43
        
44 44
        execute(""" create table if not exists public
45 45
                          ( public_id integer primary key autoincrement,
46
                            path      text ) """)
46
                            path      text not null,
47
                            active    boolean not null default 1 ) """)
47 48
        execute(""" create unique index if not exists idx_public_path
48 49
                    on public(path) """)
49 50
    
50 51
    def public_set(self, path):
51 52
        q = "insert or ignore into public (path) values (?)"
52 53
        self.execute(q, (path,))
54
        q = "update public set active = 1 where path = ?"
55
        self.execute(q, (path,))
53 56
    
54 57
    def public_unset(self, path):
55
        q = "delete from public where path = ?"
58
        q = "update public set active = 0 where path = ?"
56 59
        self.execute(q, (path,))
57 60
    
58 61
    def public_get(self, path):
59
        q = "select public_id from public where path = ?"
62
        q = "select public_id from public where path = ? and active = 1"
60 63
        self.execute(q, (path,))
61 64
        row = self.fetchone()
62 65
        if row:
......
64 67
        return None
65 68
    
66 69
    def public_path(self, public):
67
        q = "select path from public where public_id = ?"
70
        q = "select path from public where public_id = ? and active = 1"
68 71
        self.execute(q, (public,))
69 72
        row = self.fetchone()
70 73
        if row:

Also available in: Unified diff