|
From: Stas Z <sta...@gm...> - 2005-06-03 17:09:02
|
On 6/3/05, Waseem S. Daher <wd...@mi...> wrote:
> Interesting approach.
> I probably don't understand where you're going with this though, because
> I wonder why you'd want to save state internally at all?
Well the function is called from here:
try:
contacts =3D ga.getContacts().getAllContacts()
# Just to test save_contacts without having to raise an exception
save_contacts(contacts)
for contact in contacts:
if GM_DEBUG: logging.debug("Removing contact", contact)
ga.removeContact(contact)
except Exception,info:
logging.critical(str(info))
if contacts:
save_contacts(contacts)
The potential problem arises when an exception is raised after the
contacts are removed but
before the new ones are added. (More arguments below)
> Whatever lives
> in Gmail should be the definitive version of the contacts, right? So why
> would we ever need to read from them locally?
In GmailAgent I keep a local address file in the users home dir which
is a copy of the Gmail
contacts online.
GA uses this local address file to prevent logins into Gmail when it's
not really needed.
My idea was that GA should use this local file and when ever the user
changes something
it would be added/changed in the local file. Then when the 'editor' is
closed or opened the user is asked if he wants to import/export a
'fresh' contacts list from Gmail.
When importing/exporting the online list is merged with the online version.
The Gmail contacts is cleared and updated again with all the contacts
from the local file.
I hope this makes any sense, I'm in the middle of implementing it, so
I myself don't know how
the finished contacts framework will look like :-)
You could checkout GA-main and start GmailAgent.py from a xterm and
hit a few address
related buttons, it would be clear what's happening.
> Though I guess it can't hurt.
The thing that keeps bothering me about the whole contacts issue is
that there's a potential
problem with removing/adding contacts. What happens when the
application crashes in the
middle of a libgmail2 action?
You could end up with a (partly) cleared contacts list online, a
contacts list in memory
(contacts =3D ga.getContacts().getAllContacts()) and a application
that's crashed.
What can you do to save the users data?=20
write them to disk before the Python VM exits.=20
I really love apps that saves my work when crashing.
I don't mind an app that screws up but I hate a developer that doesn't save=
s my
data on a screw up. :-/
The (almost) worst thing I can imagine is a email from a GA user that tells=
me:
" GA erased my contacts list, and now I hate you forever!!"
It would be nice to reply:
"You stupid MS lover, your contacts are save and sound on your disk"
:-)
Stas
--=20
"Everything that is really great and inspiring is created by the individual
who can labor in freedom."
-Albert Einstein
|