Inheritance needed in app configuration =============================
I have an ftp server that a number of vendors connect into to upload a file to their directory. In OO terms, we would have class OurFTP: server = "ftpserver.com" class Vendor1(OurFTP) user, pass, directory = ("blah","blah","blah") etc, etc And thus when I write a Python script to go check their uploads, I need to create a VendorN object and use the user, pass and directory from VendorN but use the server attribute from the parent class Now in pure OO, this is a piece of cake. However, I thought I would use ConfigObj to configure my app because it is clean and widely used and the authors are active people. But I don't know how to get a local config to inherit global values. In other words, I have a file called global.ini with the server address in it and then each vendor has a file called local.ini with their user, pass, directory info. And I need to form an FTP connection URL based on this. But I really dont want to write my code such that I explicitly hardcode where the ftpserver is coming from. Again, in pure OO it is very simple to call a method and have it dispatch to either the current object or it's parent, but I am not sure that ConfigObj or any config module allows such power. I am starting to think that I better just do my configuration information in Python classes to get the genericity that I want. Program Code =========== Just in case you want to see what I'm doing, here's the relevant section of code: config = ConfigObj("local.ini") gconfig = ConfigObj("../generic.ini") """Curry function by Bruno Desthuilliers http://groups.google.com/group/comp.lang.python/browse_thread/thread/b2af1cc34aab085e/c31e388ff0bb4e9c?lnk=gst&q=curry&rnum=10#c31e388ff0bb4e9c curry() will be part of py2.5 """ def curry(fun, *args): def _curried(*moreargs): return fun(*(args + moreargs)) _curried.func_name = "curried(%s) of %r" % (", ".join(args), fun) return _curried def getkey(k1,k2): return config[k1][k2] # -------------------------------------------------------------------------- # Fetch DMS file from KE FTP # -------------------------------------------------------------------------- ftp_cfg_keys = "filepattern user pass cwd".split() ftp_lambda = curry(getkey, 'ftp_in') ftp_cmd_vals = map(ftp_lambda, ftp_cfg_keys) print ftp_cmd_vals # the !!! should be filled in with the globally configured FTP server # but I refuse to play telepathic guru and point to the source directly # if I have to write this over and use pure Python OO instead of a # config module then so be it ftp_cmd = "mget %s | ftp -i ftp://%s:[EMAIL PROTECTED]/%s" % tuple(ftp_cmd_vals) print ftp_cmd os.system(ftp_cmd) sys.exit() Aside ==== When it comes to HTML generation, every form of mini-language that I've seen does not appeal to me. I use DOM to rewrite HTML. I hate the limitations of mini-languages and prefer full-strength programming languages. Now it is appearing that application configuration is yet one more place to avoid mini-language convenience and simply use a programming language for the task. -- http://mail.python.org/mailman/listinfo/python-list