X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fstorage%2Frecord.py;h=812efdeba29a6058ffc8a15b99e46a31861e5739;hb=1cc8e9613cab8b5b22478de369f259e591c54e6d;hp=6e58d102bea504b561c6888be3d5741dac0a9e2f;hpb=2be379dd1f4e8e74de143fb6c7c530d11b128c8b;p=sfa.git diff --git a/sfa/storage/record.py b/sfa/storage/record.py index 6e58d102..812efdeb 100644 --- a/sfa/storage/record.py +++ b/sfa/storage/record.py @@ -33,14 +33,15 @@ class Record: # fallback return "** undef_datetime **" - # it may be important to exclude relationships - def todict (self, exclude_type=None): + # it may be important to exclude relationships, which fortunately + # + def todict (self, exclude_types=[]): d=self.__dict__ def exclude (k,v): if k.startswith('_'): return True - if exclude_type: - if isinstance (v,exclude_type): return True - if isinstance (v,list) and v and isinstance (v[0],exclude_type) : return True + if exclude_types: + for exclude_type in exclude_types: + if isinstance (v,exclude_type): return True return False keys=[k for (k,v) in d.items() if not exclude(k,v)] return dict ( [ (k,d[k]) for k in keys ] )