[Pulp-list] Importer/Distributor API Change

Jay Dobies jason.dobies at redhat.com
Fri Mar 9 15:50:30 UTC 2012


The validate_config method used to return a boolean as to whether or not 
the config is valid. That makes for a really annoying user experience 
since the user doesn't really have a clue _why_ it failed. I'm trying to 
avoid having to tell users "check the server logs" in v2.

The change is that it now returns a tuple of result (bool) and message 
(str), where the message should describe what/why it failed.

Admittedly I went back and forth on tuple v. a first class object to 
allow for future functionality, but I just couldn't figure out what else 
should go in there besides result and message. The change only took like 
10 min though so if there's a compelling argument in favor of something 
besides a tuple it's not a huge deal for me to change it.

Here's the relevant docstrings from the importer API:

==
   The return is a tuple of the result of the validation (True for
   success, False for failure) and a message. The message may be
   None and is unused in the success case. For a failed validation,
   the message will be communicated to the caller so the plugin
   should take i18n into consideration when generating the message.
==

I made it backward compatible with the current APIs, so if you only 
return a single boolean you'll keep working (Pulp will use None as the 
message field). But please try to update this as soon as you can so we 
can show users more information on why the config was invalid.

These changes are in master now (well, the distributor ones will be 
there shortly) and will be in the next QE build.

-- 
Jay Dobies
Freenode: jdob @ #pulp
http://pulpproject.org | http://blog.pulpproject.org




More information about the Pulp-list mailing list