diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1998-05-26 13:39:57 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1998-05-26 13:39:57 +0000 |
commit | 55f9e738e524be7e37f24e925d74d87da4e4323e (patch) | |
tree | 17db810c1cb642a92eee48ba2cd325dc8be9f728 | |
parent | cab4cbe5c3c35711230da68bfde86cb9401172e3 (diff) | |
download | fetchmail-55f9e738e524be7e37f24e925d74d87da4e4323e.tar.gz fetchmail-55f9e738e524be7e37f24e925d74d87da4e4323e.tar.bz2 fetchmail-55f9e738e524be7e37f24e925d74d87da4e4323e.zip |
First step towards abstracting out post/gather.
svn path=/trunk/; revision=1850
-rwxr-xr-x | fetchmailconf | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/fetchmailconf b/fetchmailconf index 04cea1c3..42a8846f 100755 --- a/fetchmailconf +++ b/fetchmailconf @@ -708,7 +708,30 @@ you will open a window to configure the user's options on that site. """} -class ServerEdit(Frame): +class MyWidget: +# Common methods for Tkinter Widgets + def post(self, template, field): + for x in template.typemap: + target = "self." + x[0] + source = "self." + field + "." + x[0] + if x[1] == 'Boolean': + exec target + " = BooleanVar(self)" + if eval(source): + exec target + ".set(" + source + ")" + elif x[1] == 'String': + exec target + " = StringVar(self)" + if eval(source): + exec target + ".set(" + source + ")" + elif x[1] == 'Int': + exec target + " = IntVar(self)" + if eval(source): + exec target + ".set(" + source + ")" + + def gather(self, template, field): + for x in template.typemap: + setattr(eval("self." + field), x[0], getattr(self, x[0]).get()) + +class ServerEdit(Frame, MyWidget): def __init__(self, host, servers): self.server = None for site in servers: @@ -725,42 +748,18 @@ class ServerEdit(Frame): Pack.config(self) self.master.title('Fetchmail host ' + self.server.pollname); self.master.iconname('Fetchmail host ' + self.server.pollname); - self.post() + self.post(Server, 'server') self.makeWidgets(self.server.pollname, mode) # self.grab_set() # self.focus_set() # self.wait_window() - def post(self): - # we can't abstract this away, execs would happen in the wrong scope - for x in Server.typemap: - target = "self." + x[0] - source = "self.server." + x[0] - if x[1] == 'Boolean': - exec target + " = BooleanVar(self)" - if eval(source): - exec target + ".set(" + source + ")" - elif x[1] == 'String': - exec target + " = StringVar(self)" - if eval(source): - exec target + ".set(" + source + ")" - elif x[1] == 'Int': - exec target + " = IntVar(self)" - if eval(source): - exec target + ".set(" + source + ")" - - def gather(self): - for x in Server.typemap: - setattr(self.server, x[0], getattr(self, x[0]).get()) - def nosave(self): if ConfirmQuit(self, 'server option editing'): Widget.destroy(self.master) def save(self): - self.gather() - for u in self.server.users: - print "Attempting to save for a user named " + u.remote + self.gather(Server, 'server') Widget.destroy(self.master) def refreshPort(self): |