def dbDecode(dataString): assert_arg_type(dataString, basestring) ## this logic is poor - I believe the best way is to define a standard set of ## representation formats and use try..except clauses to parse the incoming string ## according to the defined formats (formats: text, json, xml) ## For now we treat it as a default of text ## use tastypie's serializer to do the testing from tastypie.serializers import Serializer ## instantiate a serializer to test serdes = Serializer() dataobj = None val = None try: val = serdes.from_xml(dataString) except Exception: val = None if val is None: try: from django.utils import simplejson #val = serdes.from_json(dataString) val = simplejson.loads(dataString, encoding='utf-8') except Exception, ex: val = None if not isinstance(val, (dict, list)): val = str(dataString) dataobj = Data(val, data_format = Data.TEXT) else: dataobj = Data(val, data_format = Data.JSON)
def dbDecode(dataString): assert_arg_type(dataString, basestring) ## this logic is poor - I believe the best way is to define a standard set of ## representation formats and use try..except clauses to parse the incoming string ## according to the defined formats (formats: text, json, xml) ## For now we treat it as a default of text ## use tastypie's serializer to do the testing from tastypie.serializers import Serializer ## instantiate a serializer to test serdes = Serializer() dataobj = None val = None try: val = serdes.from_xml(dataString) except Exception: val = None if val is None: try: from django.utils import simplejson #val = serdes.from_json(dataString) val = simplejson.loads(dataString, encoding='utf-8') except Exception, ex: val = None if not isinstance(val, (dict, list)): val = str(dataString) dataobj = Data(val, data_format=Data.TEXT) else: dataobj = Data(val, data_format=Data.JSON)
def setLimit(self, limit): assert_arg_type(limit, int) self.limit = limit
def setList(self, argList): assert_arg_type(argList, list) assert_arg_list_type(argList, self.elemType) self.argList = argList
def removeItem(self, item): assert_arg_type(item, self.elemType) self.argList.remove(item)
def addItem(self, item): assert_arg_type(item, self.elemType) self.argList.append(item)
def __init__(self, lat, long): assert_arg_type(lat, float) assert_arg_type(long, float) self.lat = lat self.long = long
def __init__(self, x, y): assert_arg_type(x, float) assert_arg_type(y, float) self._x = x self._y = y
def __init__(self, lat, long): assert_arg_type(lat, float) assert_arg_type(long, float) self.lat = lat self.long = long
def __init__(self, x, y): assert_arg_type(x, float) assert_arg_type(y, float) self._x = x self._y = y
def setLimit(self, limit): assert_arg_type(limit, int) self.limit = limit
def setList(self, argList): assert_arg_type(argList, list) assert_arg_list_type(argList, self.elemType) self.argList = argList
def removeItem(self, item): assert_arg_type(item, self.elemType) self.argList.remove(item)
def addItem(self, item): assert_arg_type(item, self.elemType) self.argList.append(item)