Repository navigation
Conversation
|
Needs test. |
|
Looks as if we won't implement this, at least not in this way. close? |
|
I vote we leave it open / in draft until an alternative implementation presents itself. Is there a reason you want to close this? |
No reason. I think we decided it's best implemented as a specific query. |
|
We need to do more investigative work for #561. Let's keep this in draft for now. We can circle back once the 3.0.0 milestone is complete. |
|
Hm. Looks like I force-pushed over the old branch. Note for the future, don't do that. (Look for pre-existence of the branch name in GitHub. Duh.) Well, luckily I am very confident of the new code being better.... |
|
Will mark ready for review once I've run the tests through with rudra's changes included |
A query is done to determine the highest permission level the given user (or group) has on the target collection/data_object. A specific query will be used if the calling user has the availability, otherwise a reasonably efficient general query is used instead.
|
|
||
| # Find out if the query is already registered. | ||
| try: | ||
| specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('getMaximumPermissionForPath',)) |
There was a problem hiding this comment.
i think we've leaned into snake case...
| specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('getMaximumPermissionForPath',)) | |
| specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('get_maximum_permission_for_path',)) |
There was a problem hiding this comment.
i think we've leaned into snake case...
maybe. It will be the first one using snake case, I guess.
There was a problem hiding this comment.
i think we've done it before. certainly for other policy work that needed them...
There was a problem hiding this comment.
Noting here that the SpecificQueries used by the logical quotas REP use snake case. I like snake case, but I don't feel strongly about it either way.
| SQL=''' | ||
| WITH target_user AS ( | ||
| SELECT user_id | ||
| FROM r_user_main | ||
| WHERE user_name = ? | ||
| AND zone_name = ? | ||
| ), | ||
| resolved_object AS ( | ||
| -- The path names a collection |
There was a problem hiding this comment.
Is there a reason this specific query isn't part of irods/irods rather than the PRC?
There was a problem hiding this comment.
It will be. Meanwhile, things work whether or not there is a pre-packaged query. Baby steps I think - as we also haven't yet discussed and definitively decided an alias name for this query.
Is there a reason this specific query isn't part of irods/irods rather than the PRC?
There was a problem hiding this comment.
if it's going to work regardless of whether it's already in the server... then the client code doesn't have to define the specific query... right?
There was a problem hiding this comment.
That's correct. We typically do not make clients add SpecificQueries even if it's possible.
There was a problem hiding this comment.
I'm down with that.
| # Find out if the query is already registered. | ||
| try: | ||
| specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('getMaximumPermissionForPath',)) | ||
| specific_query.execute() | ||
| except CAT_NO_ROWS_FOUND: | ||
| specific_query = None | ||
| else: | ||
| specific_query = SpecificQuery(ses, alias='getUserAccessType', args=specific_query_args) | ||
|
|
||
| # If there is no canned query available, and we are a rodsadmin, then install our own: | ||
| if not specific_query and ses.users.get(ses.username).type == 'rodsadmin': | ||
| specific_query = UserAccessTypeQuery(ses, args=specific_query_args) |
There was a problem hiding this comment.
Auto-installing a specific query is not how we've done things in the past.
We should just try to use it and if it's there, we're good. If not, use the fallback implementation. No need to test for existence.
There was a problem hiding this comment.
but this is better for testing, in the mean time, so it might be better to leave it there until an iRODS release containing the new specific query.
There was a problem hiding this comment.
If it's for test purposes, have the test explicitly add/remove the SpecificQuery. It's fine if the test tests for existence of the SpecificQuery before adding/removing it.
|
|
||
| class AccessManager(Manager): | ||
|
|
||
| def get_maximum_permission_for_path(self, |
There was a problem hiding this comment.
Missing documentation.
| coll=None, | ||
| data=None, |
There was a problem hiding this comment.
Consider using more letters for the parameter names.
coll is pretty obvious, but data isn't.
| force_genquery=False, | ||
| feedback=None, | ||
| return_type = irods.access.return_type.INTEGER |
There was a problem hiding this comment.
What do these parameters mean/do?
There was a problem hiding this comment.
force_genquery - use genquery regardless of the availability or permissions for using a specific query (good for testing, at present)
feedback - gives caller the method of query used. ('general', 'specific')
return_type - determines whether eg. 'own' or 1200 is returned.
There was a problem hiding this comment.
Are feedback and return_type meant for users or testing? Can you explain when someone might use those?
There was a problem hiding this comment.
feedback is of utility for thorough testing , use is only important if the calling application is interested which query type was used. Otherwise we could replace it with logging.
return_type converts the integer to a string such as modify_object or own before returning. I don't know if this is preferable to letting the application do the conversion instead. Thoughts?
There was a problem hiding this comment.
feedbackis of utility for thorough testing , use is only important if the calling application is interested which query type was used. Otherwise we could replace it with logging.
If it's purely for testing, logging or thorough manual testing is sufficient. You can leave a big fat comment in the code for the next developer to be careful not to break the implementation.
return_typeconverts the integer to a string such asmodify_objectorownbefore returning. I don't know if this is preferable to letting the application do the conversion instead. Thoughts?
Hmm. If the SpecificQuery returns both the symbolic name and integer, then we can return a tuple containing them. Otherwise, I think we should pick one. If we have to pick one, I think the symbolic name is slightly stronger since it's used through out our docs and APIs.
| class return_type(enum.Enum): | ||
| INTEGER = 1 | ||
| STRING = 2 |
| return response | ||
|
|
||
| def execute(self, limit=MAX_SQL_ROWS, offset=0, options=0, conditions=None): | ||
| def execute(self, limit=MAX_SQL_ROWS, offset=0, options=0, conditions=None, instance=None): |
There was a problem hiding this comment.
What does instance do?
There was a problem hiding this comment.
executes from an alternative instance of the class, other than self. I will review this and make a more complete answer later. Ideally this shouldn't have been necessary.
Check if the
usernamed (may be a user or group) has privilege at or above the givenaccess_levelto the collection or data object named bypath