On Wed, Aug 05, 2009 at 01:48:09PM +0100, Guido Trotter wrote:
> 
> If a value is None, there's no point exporting it in the relevant dict
> representation for an object: it will be None again when the object is
> loaded by FromDict. This has the nice side effect of removing
> "deprecated" slots from the config file.
> 
> Signed-off-by: Guido Trotter <[email protected]>
> ---
>  lib/objects.py |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/objects.py b/lib/objects.py
> index 6be372b..b6526fc 100644
> --- a/lib/objects.py
> +++ b/lib/objects.py
> @@ -126,7 +126,8 @@ class ConfigObject(object):
>      make sure all objects returned are only standard python types.
>  
>      """
> -    return dict([(k, getattr(self, k, None)) for k in self.__slots__])
> +    return dict([(k, getattr(self, k, None)) for k in self.__slots__
> +                 if getattr(self, k, None) is not None])

If you do this, you should also modify the __getstate__ method to not
return the None items.

iustin

Reply via email to