Driver selection
Gabriel Genellina
gagsl-py at yahoo.com.ar
Sat Dec 9 00:35:41 EST 2006
On 9 dic, 00:53, "Stuart D. Gathman" <stu... at bmsi.com> wrote:
> The pyspf package [http://cheeseshop.python.org/pypi/pyspf/] can use
> either pydns, or dnspython. The pyspf module has a simple driver
> function, DNSLookup(), that defaults to the pydns version. It can be
> assigned to a dnspython version, or to a test driver for in memory DNS.
> Or you can modify the source to "from drivermodule import DNSLookup".
>
> What is the friendliest way to make this configurable? Currently, users
> are modifying the source to supply the desired driver. Yuck. I would
> like to supply several drivers, and have a simple way to select one at
> installation or run time.
You can store the user's choice in a configuration file (like the ones
supported by ConfigParser).
Then you can put all the logic to select and import the right function
in a separate module, and export the DNSLookup name; make all the other
parts of the application say "from mymodule import DNSLookup"
--
Gabriel Genellina
More information about the Python-list
mailing list