[spambayes-dev] Options changes

Mark Hammond mhammond at skippinet.com.au
Mon Jun 16 12:20:12 EDT 2003


I am making a few changes to Options that I will detail a little later, but
there are a couple of things that I would like some feedback on:

1) Options does a simple "print" for invalid values.  Eg:
            print "Attempted to set [%s] %s with invalid value %s (%s)" % \
                  (sect, opt, val, type(val))

  It makes sense to me that an exception would be better here.  It would
prevent strange "silent" errors in programs, and would also allow programs
to lean on the validation code already in place (ie, they could catch the
exception and tell the user).

  We would need to ensure that when loading a file (which the user may have
edited), these errors are simply printed and the file load continues.  But
when the program itself is setting the option to an invalid value, an
exception would be more useful.

Can anyone tell me quickly how pop3proxy's config server validates the form
input?

2) Saving to a temp file.  Currently we use TemporaryFile() then
shutil.copyfileobj it to the real file.  These may be on different devices.
It makes more sense to me to save it to a ".tmp" file in the correct
directory, then remove and move the file across.  It wouldn't be
thread-safe, but a) not much else here is, and b) and "thread-safe" program
that tries to write to the same config file at the same time is insane
anyway <wink>.  These config files are likely to be small, so it isn't
really a big deal, but still did strike me.

Any thoughts on either of these?

Mark.




More information about the spambayes-dev mailing list