[hg] galaxy 1527: Some metadata updates.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[hg] galaxy 1527: Some metadata updates.

greg
details:   http://www.bx.psu.edu/hg/galaxy/rev/b6420d2f247c
changeset: 1527:b6420d2f247c
user:      Dan Blankenberg <[hidden email]>
date:      Wed Sep 24 13:52:01 2008 -0400
description:
Some metadata updates.

3 file(s) affected in this change:

lib/galaxy/datatypes/metadata.py
lib/galaxy/model/__init__.py
lib/galaxy/tools/__init__.py

diffs (84 lines):

diff -r 38e533287df4 -r b6420d2f247c lib/galaxy/datatypes/metadata.py
--- a/lib/galaxy/datatypes/metadata.py Wed Sep 24 11:14:44 2008 -0400
+++ b/lib/galaxy/datatypes/metadata.py Wed Sep 24 13:52:01 2008 -0400
@@ -155,11 +155,8 @@
         else: self.spec = spec
         
         #set default metadata values
-        if not self.parent._metadata:
+        if self.parent._metadata is None:
             self.parent._metadata = {}
-        for name, value in self.spec.items():
-            if name not in self.bunch:
-                self.bunch[name] = value.default
         
     def __iter__(self):
         return self.bunch.__iter__()
@@ -177,12 +174,10 @@
     def __getattr__(self, name):
         if name == "bunch":
             return self.parent._metadata
-        rval = self.bunch.get( name )
-        if rval is None:
-            rval = self.spec.get( name, None )
-            if rval:
-                rval = rval.no_value
-        return rval
+        if name in self.bunch:
+            return self.bunch[name]
+        if name in self.spec:
+            return self.spec[name].default
     def __setattr__(self, name, value):
         if name in ["parent","spec"]:
             self.__dict__[name] = value
diff -r 38e533287df4 -r b6420d2f247c lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py Wed Sep 24 11:14:44 2008 -0400
+++ b/lib/galaxy/model/__init__.py Wed Sep 24 13:52:01 2008 -0400
@@ -5,7 +5,7 @@
 the relationship cardinalities are obvious (e.g. prefer Dataset to Data)
 """
 
-import os.path, os, errno
+import os.path, os, errno, copy
 import sha
 import galaxy.datatypes
 from galaxy.util.bunch import Bunch
@@ -114,7 +114,8 @@
         self.extension = extension
         self.designation = designation
         self.metadata = metadata or dict()
-        self.dbkey = dbkey
+        if dbkey: #dbkey is stored in metadata, only set if non-zero, or else we could clobber one supplied by input 'metadata'
+            self.dbkey = dbkey
         self.deleted = deleted
         self.visible = visible
         # Relationships
@@ -164,7 +165,7 @@
         return self._metadata_collection
     def set_metadata( self, bunch ):
         # Needs to accept a MetadataCollection, a bunch, or a dict
-        self._metadata = dict( bunch.items() )
+        self._metadata = dict( [ ( key, copy.deepcopy( value ) ) for key, value in bunch.items() ] )
     metadata = property( get_metadata, set_metadata )
 
     """
diff -r 38e533287df4 -r b6420d2f247c lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py Wed Sep 24 11:14:44 2008 -0400
+++ b/lib/galaxy/tools/__init__.py Wed Sep 24 13:52:01 2008 -0400
@@ -1185,6 +1185,7 @@
                 primary_data.info = dataset.info
                 primary_data.state = primary_data.states.OK
                 primary_data.init_meta( copy_from=dataset )
+                primary_data.set_meta()
                 primary_data.set_peek()
                 primary_data.set_size()
                 primary_data.flush()
@@ -1245,6 +1246,8 @@
         def __getattr__( self, name ):
             rval = self.metadata.get( name, None )
             if name in self.metadata.spec:
+                if rval is None:
+                    rval = self.metadata.spec[name].no_value
                 rval = self.metadata.spec[name].wrap( rval, self.metadata.parent )
             return rval
         def __nonzero__( self ):