Changeset 184:df8c944309b4 in livinglogic.python.orasql
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
r182
|
r184
|
|
434 | 434 | def iterprivileges(self, schema="user"): |
435 | 435 | """ |
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> |
438 | 438 | <par><arg>schema</arg> specifies from which privileges should be |
439 | 439 | yielded:</par> |
440 | 440 | <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> |
443 | 443 | <term><lit>"all"</lit></term><item>All object privileges will be yielded.</item> |
444 | 444 | </dlist> |
… |
… |
|
450 | 450 | |
451 | 451 | 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") |
455 | 455 | for rec in cursor.fetchall(): |
456 | 456 | yield Privilege(rec.privilege, rec.object, rec.grantee, rec.owner, cursor.connection) |
… |
… |
|
1889 | 1889 | def __init__(self, privilege, object, grantee, owner=None, connection=None): |
1890 | 1890 | self.privilege = privilege |
1891 | | self.object = object # might include an owner name |
| 1891 | self.object = object |
1892 | 1892 | self.grantee = grantee |
1893 | 1893 | self.owner = owner |