Re: Opinions sought on best practice
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 09/22/2013 08:25 PM, Anne Ogborn wrote: > > Weblog is essentially a bunch of wrappers for other API's. That means we have a lot of external keys > we have to handle - e.g. if you're going to use a google map you have to provide them a map key. > > Currently we have checked in a googlemapkey.pl.example file that has a few lines of comment saying where > to get the API and a single line that defines the key, with PUT THE KEY HERE in it. > > Obviously we don't have googlemapkey.pl checked in because it contains a password (the map key). > We don't want to hand out our keys, and don't want to clobber others keys with ours when they update weblog. > > Presumably this ends up in a settings file, but I'm unsure what best practice is here. > > Should there be a settings file for each item, or a single settings file, with each one loaded only as it's > associated widget file is loaded (eg the google maps key is loaded with google maps, the stormpath key with stormpath)? > > And whats the proper way of using default settings and of handling an undefined setting? Currently I have > an unlikely value like this_is_not_the_key as the default and check for it, but am uncomfortable with that. > > (The UX is pretty settled - it substitutes an inclusion that says there's a missing key and has a button to the page to get it). This is basically what library(settings) was designed for. ClioPatria uses it in many places and provides an HTTP service to examine and change the settings. Surely, you do not want people to edit source files for addings keys and other parameters because this upsets updating, version management and sharing. library(settings) allows defining a setting with comment, type and default value. Settings can be changed and saved using predicate calls. Finally, applications that combine files that define settings may call set_setting_default/2 to change the default value of a setting. Cheers --- Jan > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog >