Skip to content

Instantly share code, notes, and snippets.

@natefoo
Created May 21, 2013 19:32
Show Gist options
  • Save natefoo/5622535 to your computer and use it in GitHub Desktop.
Save natefoo/5622535 to your computer and use it in GitHub Desktop.
diff -r 2b456e221582 lib/galaxy/datatypes/metadata.py
--- a/lib/galaxy/datatypes/metadata.py Mon May 20 16:51:05 2013 -0400
+++ b/lib/galaxy/datatypes/metadata.py Tue May 21 15:31:59 2013 -0400
@@ -85,8 +85,8 @@
def __getattr__( self, name ):
if name in self.spec:
if name in self.parent._metadata:
- return self.spec[name].wrap( self.parent._metadata[name] )
- return self.spec[name].wrap( self.spec[name].default )
+ return self.spec[name].wrap( self.parent._metadata[name], object_session( self.parent ) )
+ return self.spec[name].wrap( self.spec[name].default, object_session( self.parent ) )
if name in self.parent._metadata:
return self.parent._metadata[name]
def __setattr__( self, name, value ):
@@ -213,7 +213,7 @@
self.validate( value )
return value
- def wrap( self, value ):
+ def wrap( self, value, session ):
"""
Turns a value into its usable form.
"""
@@ -256,11 +256,11 @@
def get( self, name, default=None ):
return self.__dict__.get(name, default)
- def wrap( self, value ):
+ def wrap( self, value, session ):
"""
Turns a stored value into its usable form.
"""
- return self.param.wrap( value )
+ return self.param.wrap( value, session )
def unwrap( self, value ):
"""
@@ -323,7 +323,7 @@
return ", ".join( map( str, value ) )
return MetadataParameter.get_html( self, value, context=context, other_values=other_values, values=values, **kwd )
- def wrap( self, value ):
+ def wrap( self, value, session ):
value = self.marshal( value ) #do we really need this (wasteful)? - yes because we are not sure that all existing selects have been stored previously as lists. Also this will handle the case where defaults/no_values are specified and are single non-list values.
if self.multiple:
return value
@@ -435,17 +435,18 @@
def get_html( self, value=None, context={}, other_values={}, **kwd ):
return "<div>No display available for Metadata Files</div>"
- def wrap( self, value ):
+ def wrap( self, value, session ):
if value is None:
return None
if isinstance( value, galaxy.model.MetadataFile ) or isinstance( value, MetadataTempFile ):
return value
- mf = galaxy.model.MetadataFile()
- mf.id = value #we assume this is a valid id, since we cannot check it
+ mf = session.query( galaxy.model.MetadataFile ).get( value )
+ #mf = galaxy.model.MetadataFile()
+ #mf.id = value #we assume this is a valid id, since we cannot check it
return mf
def make_copy( self, value, target_context, source_context ):
- value = self.wrap( value )
+ value = self.wrap( value, object_session( target_context.parent ) )
if value:
new_value = galaxy.model.MetadataFile( dataset = target_context.parent, name = self.spec.name )
object_session( target_context.parent ).add( new_value )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment