1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/89190bcd1ccf/ changeset: r5074:89190bcd1ccf user: dannon date: 2011-02-16 19:50:30 summary: Quick fix for postgres9 JSONType/MetadataType hex decoding issues. Todo: Postgres9 might be configurable to do this natively, postgres8 does not have the issue. affected #: 1 file (305 bytes)
--- a/lib/galaxy/model/custom_types.py Wed Feb 16 13:48:14 2011 -0500 +++ b/lib/galaxy/model/custom_types.py Wed Feb 16 13:50:30 2011 -0500 @@ -4,6 +4,7 @@ import simplejson import pickle import copy +import binascii from galaxy.util.bunch import Bunch from galaxy.util.aliaspickler import AliasPickleModule
@@ -14,8 +15,20 @@ json_encoder = simplejson.JSONEncoder( sort_keys=True ) json_decoder = simplejson.JSONDecoder( )
+def _sniffnfix_pg9_hex(value): + """ + Sniff for and fix postgres 9 hex decoding issue + """ + try: + if value[0] == 'x': + return binascii.unhexlify(value[1:]) + else: + return value + except Exception, ex: + return value + class JSONType( TypeDecorator ): - """ + """ Defines a JSONType for SQLAlchemy. Takes a primitive as input and JSONifies it. This should replace PickleType throughout Galaxy. """ @@ -29,16 +42,16 @@ def process_result_value( self, value, dialect ): if value is None: return None - return json_decoder.decode( str( value ) ) - + return json_decoder.decode( str( _sniffnfix_pg9_hex(value) ) ) + def copy_value( self, value ): # return json_decoder.decode( json_encoder.encode( value ) ) return copy.deepcopy( value )
def compare_values( self, x, y ): - # return json_encoder.encode( x ) == json_encoder.encode( y ) - return ( x == y ) - + # return json_encoder.encode( x ) == json_encoder.encode( y ) + return ( x == y ) + def is_mutable( self ): return True
@@ -61,11 +74,11 @@ ret = dict( ret.__dict__ ) except: try: - ret = json_decoder.decode( str( value ) ) + ret = json_decoder.decode( str( _sniffnfix_pg9_hex(value) ) ) except: ret = None return ret - + class TrimmedString( TypeDecorator ): impl = String def process_bind_param( self, value, dialect ): @@ -73,4 +86,4 @@ if self.impl.length and value is not None: value = value[0:self.impl.length] return value - +
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.