Changeset 820 for trunk/pg.py


Ignore:
Timestamp:
Feb 5, 2016, 9:04:31 AM (3 years ago)
Author:
cito
Message:

Skip test for privileges when running as superuser

It's not possible to test for missing privileges as a superuser
because superusers always have all privileges.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pg.py

    r818 r820  
    17901790            return regtypes
    17911791
    1792     def has_table_privilege(self, table, privilege='select'):
    1793         """Check whether current user has specified table privilege."""
     1792    def has_table_privilege(self, table, privilege='select', flush=False):
     1793        """Check whether current user has specified table privilege.
     1794
     1795        If flush is set, then the internal cache for table privileges will
     1796        be flushed. This may be necessary after privileges have been changed.
     1797        """
     1798        privileges = self._privileges
     1799        if flush:
     1800            privileges.clear()
     1801            self._do_debug('The privileges cache has been flushed')
    17941802        privilege = privilege.lower()
    17951803        try:  # ask cache
    1796             return self._privileges[(table, privilege)]
     1804            ret = privileges[table, privilege]
    17971805        except KeyError:  # cache miss, ask the database
    17981806            q = "SELECT has_table_privilege(%s, $2)" % (
     
    18001808            q = self.db.query(q, (table, privilege))
    18011809            ret = q.getresult()[0][0] == self._make_bool(True)
    1802             self._privileges[(table, privilege)] = ret  # cache it
    1803             return ret
     1810            privileges[table, privilege] = ret  # cache it
     1811        return ret
    18041812
    18051813    def get(self, table, row, keyname=None):
Note: See TracChangeset for help on using the changeset viewer.