Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 def setLimit(self, limit):
     assert_arg_type(limit, int)
     self.limit = limit
Exemplo n.º 4
0
 def setList(self, argList):
     assert_arg_type(argList, list)
     assert_arg_list_type(argList, self.elemType)
     self.argList = argList
Exemplo n.º 5
0
 def removeItem(self, item):
     assert_arg_type(item, self.elemType)
     self.argList.remove(item)
Exemplo n.º 6
0
 def addItem(self, item):
     assert_arg_type(item, self.elemType)
     self.argList.append(item)
Exemplo n.º 7
0
 def __init__(self, lat, long):
     assert_arg_type(lat, float)
     assert_arg_type(long, float)
     self.lat = lat
     self.long = long
Exemplo n.º 8
0
 def __init__(self, x, y):
     assert_arg_type(x, float)
     assert_arg_type(y, float)
     self._x = x
     self._y = y
Exemplo n.º 9
0
 def __init__(self, lat, long):
     assert_arg_type(lat, float)
     assert_arg_type(long, float)
     self.lat = lat
     self.long = long
Exemplo n.º 10
0
 def __init__(self, x, y):
     assert_arg_type(x, float)
     assert_arg_type(y, float)
     self._x = x
     self._y = y
Exemplo n.º 11
0
 def setLimit(self, limit):
     assert_arg_type(limit, int)
     self.limit = limit
Exemplo n.º 12
0
 def setList(self, argList):
     assert_arg_type(argList, list)
     assert_arg_list_type(argList, self.elemType)
     self.argList = argList
Exemplo n.º 13
0
 def removeItem(self, item):
     assert_arg_type(item, self.elemType)
     self.argList.remove(item)
Exemplo n.º 14
0
 def addItem(self, item):
     assert_arg_type(item, self.elemType)
     self.argList.append(item)