Skip to content
jdang edited this page May 5, 2011 · 3 revisions

SugarBean class - takes the sugarcrm API sugarbean object and converts it into a python format.

This line of code convert all the value to type string

for (k,i) in entry_list['name_value_list'].iteritems():

self.__dict__[k] = str(i['value'])

class SugarBean:
    
    ## SugarBean Constructor
    # @param self the object pointer
    # @param data server response to be parsed
    def __init__(self, data):

        try:
            entry_list = data['entry_list']
        except KeyError:
            entry_list = data

        self.module = data['module_name']
        

        for (k,i) in entry_list['name_value_list'].iteritems():
self.__dict__[k] = str(i['value'])

    def __str__(self):
        return str(self.module)+':'+str(self.id)