Changeset 184:df8c944309b4 in livinglogic.python.orasql

Show
Ignore:
Timestamp:
02/01/07 18:59:31 (13 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

iterprivileges now yields the privileges for the users objects instead of
those granted by the user.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/orasql/__init__.py

    r182 r184  
    434434    def iterprivileges(self, schema="user"): 
    435435        """ 
    436         <par>Generator that yields object privileges granted by the current user 
    437         (or all users).</par> 
     436        <par>Generator that yields object privileges for the current users 
     437        (or all users) objects.</par> 
    438438        <par><arg>schema</arg> specifies from which privileges should be 
    439439        yielded:</par> 
    440440        <dlist> 
    441         <term><lit>"user"</lit></term><item>Only object privileges granted by the 
    442         current user will be yielded.</item> 
     441        <term><lit>"user"</lit></term><item>Only object privileges for objects 
     442        belonging to the current user will be yielded.</item> 
    443443        <term><lit>"all"</lit></term><item>All object privileges will be yielded.</item> 
    444444        </dlist> 
     
    450450 
    451451        if schema == "all": 
    452             cursor.execute("select decode(grantor, user, null, grantor) as owner, privilege, decode(table_schema, user, '', table_schema || '.') || table_name as object, grantee from all_tab_privs order by table_schema, table_name, privilege") 
    453         else: 
    454             cursor.execute("select null as owner, privilege, decode(owner, user, '', owner || '.') || table_name as object, grantee from user_tab_privs where grantor=user order by owner, table_name, privilege") 
     452            cursor.execute("select decode(grantor, user, null, grantor) as owner, privilege, table_name as object, grantee from all_tab_privs order by table_schema, table_name, privilege") 
     453        else: 
     454            cursor.execute("select decode(grantor, user, null, grantor) as owner, privilege, table_name as object, grantee from user_tab_privs where owner=user order by table_name, privilege") 
    455455        for rec in cursor.fetchall(): 
    456456            yield Privilege(rec.privilege, rec.object, rec.grantee, rec.owner, cursor.connection) 
     
    18891889    def __init__(self, privilege, object, grantee, owner=None, connection=None): 
    18901890        self.privilege = privilege 
    1891         self.object = object # might include an owner name 
     1891        self.object = object 
    18921892        self.grantee = grantee 
    18931893        self.owner = owner