I have a form where I feed the current data on screen as a dictionary to function to handle update/inserts.
I’m now trying to implement the old data/retrieved data from when the form is first opened, as occasionally I will need to do other database operations based on changes in certain columns.
When I turn the NonSerializingDataset that is the custom property on my root container that has all the original data to populate the form, I try to turn it into a dictionary like this -
def nonSerializingDatasetToDictionary(dataset):
"""
Takes a dataset with columns and one row and returns a dictionary where the key = column name
and value is tuple of row values in order
Args:
dataset:NonSerializingDatasetdataset, dataset you want to turn into a dictionary
Returns:
dictionary: dict, dictionary of the dataset
"""
import system.dataset
dict = {}
for row in range(dataset.getRowCount()):
for column in range(dataset.getColumnCount()):
columnName = str(dataset.getColumnName(column))
value = dataset.getValueAt(row, columnName)
dict[columnName] = value
return dict
Now when I make the dictionary, it’s just grabbing the appropriate value property from the components on screen and I get something like this -
{'sentToContact': True, 'sentToAcctNotNeeded': True, 'sentToAccounting': True, 'state': 0, 'sentToContNotNeeded': True, 'receivedConfirmation': False}
while my non serializing dataset turns into this
{'sentToContact': 0, 'sentToAcctNotNeeded': 0, 'sentToAccounting': 0, 'state': 0L, 'receivedConfirmation': 0, 'sentToContNotNeeded': 0}
I’ve tested it and all my comparisons work fine as 0 is interpreted as False and 1 as True. But why does my state
column, which has an integer value, turn to 0L
. It works, I’ve tried comparing it with 0 and it’s fine, but I was just wonderign why it says 0L
instead of just 0
.