Revision 8221c89d

b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py
219 219
            return row[0]
220 220
        return None
221 221
    
222
    def node_lookup_bulk(self, paths):
223
        """Lookup the current nodes for the given paths.
224
           Return () if the path is not found.
225
        """
226
        
227
        # Use LIKE for comparison to avoid MySQL problems with trailing spaces.
228
        s = select([self.nodes.c.node], self.nodes.c.path.in_(paths))
229
        r = self.conn.execute(s)
230
        rows = r.fetchall()
231
        r.close()
232
        return [row[0] for row in rows]
233
    
222 234
    def node_get_properties(self, node):
223 235
        """Return the node's (parent, path).
224 236
           Return None if the node is not found.
......
571 583
        self.statistics_update_ancestors(node, 1, size, mtime, cluster)
572 584
        return serial, mtime
573 585
    
574
    def version_lookup(self, node, before=inf, cluster=0):
586
    def version_lookup(self, node, before=inf, cluster=0, all_props=True):
575 587
        """Lookup the current version of the given node.
576 588
           Return a list with its properties:
577 589
           (serial, node, hash, size, type, source, mtime, muser, uuid, checksum, cluster)
......
579 591
        """
580 592
        
581 593
        v = self.versions.alias('v')
582
        s = select([v.c.serial, v.c.node, v.c.hash,
583
                    v.c.size, v.c.type, v.c.source,
584
                    v.c.mtime, v.c.muser, v.c.uuid,
585
                    v.c.checksum, v.c.cluster])
594
        if not all_props:
595
            s = select([v.c.serial])
596
        else:
597
            s = select([v.c.serial, v.c.node, v.c.hash,
598
                        v.c.size, v.c.type, v.c.source,
599
                        v.c.mtime, v.c.muser, v.c.uuid,
600
                        v.c.checksum, v.c.cluster])
586 601
        c = select([func.max(self.versions.c.serial)],
587 602
            self.versions.c.node == node)
588 603
        if before != inf:
......
596 611
            return props
597 612
        return None
598 613
    
614
    def version_lookup_bulk(self, nodes, before=inf, cluster=0, all_props=True):
615
        """Lookup the current versions of the given nodes.
616
           Return a list with their properties:
617
           (serial, node, hash, size, type, source, mtime, muser, uuid, checksum, cluster).
618
        """
619
        
620
        v = self.versions.alias('v')
621
        if not all_props:
622
            s = select([v.c.serial])
623
        else:
624
            s = select([v.c.serial, v.c.node, v.c.hash,
625
                        v.c.size, v.c.type, v.c.source,
626
                        v.c.mtime, v.c.muser, v.c.uuid,
627
                        v.c.checksum, v.c.cluster])
628
        c = select([func.max(self.versions.c.serial)],
629
            self.versions.c.node.in_(nodes)).group_by(self.versions.c.node)
630
        if before != inf:
631
            c = c.where(self.versions.c.mtime < before)
632
        s = s.where(and_(v.c.serial.in_(c),
633
                         v.c.cluster == cluster))
634
        r = self.conn.execute(s)
635
        rproxy = r.fetchall()
636
        r.close()
637
        return (tuple(row.values()) for row in rproxy)
638
        
599 639
    def version_get_properties(self, serial, keys=(), propnames=_propnames):
600 640
        """Return a sequence of values for the properties of
601 641
           the version specified by serial and the keys, in the order given.
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/permissions.py
115 115
        self.xfeature_destroy(path)
116 116
        self.public_unset(path)
117 117
    
118
    def access_clear_bulk(self, paths):
119
        """Revoke access to path (both permissions and public)."""
120
        
121
        self.xfeature_destroy_bulk(paths)
122
        self.public_unset_bulk(paths)
123
    
118 124
    def access_check(self, path, access, member):
119 125
        """Return true if the member has this access to the path."""
120 126
        
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/public.py
74 74
        r = self.conn.execute(s)
75 75
        r.close()
76 76
    
77
    def public_unset_bulk(self, paths):
78
        s = self.public.update()
79
        s = s.where(self.public.c.path.in_(paths))
80
        s = s.values(active=False)
81
        r = self.conn.execute(s)
82
        r.close()
83
    
77 84
    def public_get(self, path):
78 85
        s = select([self.public.c.public_id])
79 86
        s = s.where(and_(self.public.c.path == path,
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py
113 113
        r = self.conn.execute(s)
114 114
        r.close()
115 115
    
116
    def xfeature_destroy_bulk(self, paths):
117
        """Destroy features and all their key, value pairs."""
118
        
119
        s = self.xfeatures.delete().where(self.xfeatures.c.path.in_(paths))
120
        r = self.conn.execute(s)
121
        r.close()
122
    
116 123
    def feature_dict(self, feature):
117 124
        """Return a dict mapping keys to list of values for feature."""
118 125
        

Also available in: Unified diff