Moving MetaDataPickler out of main model module (this seems a bit cleaner)

This commit is contained in:
James Taylor
2007-10-08 19:28:00 +00:00
parent a9a72ee0ed
commit 433b118b9b
2 changed files with 7 additions and 7 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ from sqlalchemy.types import *
import simplejson
import pickle
from galaxy.util.bunch import Bunch
from galaxy.util.aliaspickler import AliasPickleModule
class JSONType( TypeDecorator ):
"""
@@ -41,13 +42,17 @@ class JSONType( TypeDecorator ):
def is_mutable( self ):
return self.mutable
MetadataPickler = AliasPickleModule( {
( "cookbook.patterns", "Bunch" ) : ( "galaxy.util.bunch" , "Bunch" )
} )
class MetadataType( JSONType ):
"""
Mixture between JSONType and PickleType...can read in either, and
writes JSON.
"""
def __init__( self, pickler=None, jsonifyer=None, mutable=True ):
def __init__( self, pickler=MetadataPickler, jsonifyer=None, mutable=True ):
self.jsonifyer = jsonifyer or simplejson
self.pickler = pickler or pickle
self.mutable = mutable
+1 -6
View File
@@ -20,11 +20,6 @@ from sqlalchemy import *
from galaxy.model import *
from galaxy.model.custom_types import *
from galaxy.util.bunch import Bunch
from galaxy.util.aliaspickler import AliasPickleModule
MetaPickler = AliasPickleModule( {
("cookbook.patterns","Bunch"):("galaxy.util.bunch","Bunch")
} )
metadata = DynamicMetaData( threadlocal=False )
context = SessionContext( create_session )
@@ -68,7 +63,7 @@ Dataset.table = Table( "dataset", metadata,
Column( "extension", TrimmedString( 64 ) ),
Column( "dbkey", TrimmedString( 64 ), key="old_dbkey" ), # maps to old_dbkey, see __init__.py
Column( "state", TrimmedString( 64 ) ),
Column( "metadata", MetadataType(pickler=MetaPickler), key="_metadata" ),
Column( "metadata", MetadataType(), key="_metadata" ),
Column( "parent_id", Integer, nullable=True ),
Column( "designation", TrimmedString( 255 ) ),
Column( "deleted", Boolean ),