Skip to content

Commit

Permalink
Do not encode dict items that start with 'metadata_' in return value …
Browse files Browse the repository at this point in the history
…of api/tools/create.

Resolves #2423, #2137, and galaxyproject/tools-iuc#770. However, this whole act of encoding by key.endswith('_id') is very messy.
  • Loading branch information
blankenberg committed Jun 6, 2016
1 parent 58f3f5c commit edca79a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/web/security/__init__.py
Expand Up @@ -54,13 +54,13 @@ def encode_id( self, obj_id, kind=None ):
# Encrypt
return id_cipher.encrypt( s ).encode( 'hex' )

def encode_dict_ids( self, a_dict, kind=None ):
def encode_dict_ids( self, a_dict, kind=None, skip_startswith=None ):
"""
Encode all ids in dictionary. Ids are identified by (a) an 'id' key or
(b) a key that ends with '_id'
"""
for key, val in a_dict.items():
if key == 'id' or key.endswith('_id'):
if key == 'id' or key.endswith('_id') and ( skip_startswith is None or not key.startswith( skip_startswith ) ):
a_dict[ key ] = self.encode_id( val, kind=kind )

return a_dict
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/tools.py
Expand Up @@ -278,7 +278,7 @@ def create( self, trans, payload, **kwd ):
# so it's possible to figure out which newly created elements
# correspond with which tool file outputs
output_dict[ 'output_name' ] = output_name
outputs.append( trans.security.encode_dict_ids( output_dict ) )
outputs.append( trans.security.encode_dict_ids( output_dict, skip_startswith="metadata_" ) )

for job in vars.get('jobs', []):
rval[ 'jobs' ].append( self.encode_all_ids( trans, job.to_dict( view='collection' ), recursive=True ) )
Expand Down

0 comments on commit edca79a

Please sign in to comment.