Skip to main content

Ralsina.Me — Roberto Alsina's website

Baby steps

Im­ple­ment­ing prop­er up­dat­ing is sim­ple in that send­ing stuff to PyDS is sim­ple. How­ev­er, hav­ing the GUI do the right thing is trick­y:

When you mod­i­fy an en­try and switch to an­oth­er, you have to of­fer a chance to save or dis­card.

If the us­er dis­card­s, you have to go back to the orig­i­nal data, so it must be saved some­where else. And re­mem­ber this:

>>> a={}
>>> b=a
>>> a['x']=1
>>> b['x']
1

Yeah, ob­vi­ous python se­man­tic­s. Lost an hour, though ;-)

What you want to do in­stead is:

b=copy.deepcopy(a)

If he saves, you have to up­load.

Al­so, when he mod­i­fies, you have to up­date the post list re­al­time, so you see a co­her­ent en­ti­ty. Not too hard, but it forces you to despaghet­tize code some­what.


Contents © 2000-2024 Roberto Alsina