X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fstorage%2Frecord.py;h=812efdeba29a6058ffc8a15b99e46a31861e5739;hb=1cc8e9613cab8b5b22478de369f259e591c54e6d;hp=f3aa8ee9b620f668e0e5939f9f76845f09092cb2;hpb=6e46a2373bcda1c1793d18936cc40fb39beb149a;p=sfa.git diff --git a/sfa/storage/record.py b/sfa/storage/record.py index f3aa8ee9..812efdeb 100644 --- a/sfa/storage/record.py +++ b/sfa/storage/record.py @@ -33,9 +33,17 @@ class Record: # fallback return "** undef_datetime **" - def todict (self): + # it may be important to exclude relationships, which fortunately + # + def todict (self, exclude_types=[]): d=self.__dict__ - keys=[k for k in d.keys() if not k.startswith('_')] + def exclude (k,v): + if k.startswith('_'): 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 ] ) def toxml(self): @@ -91,7 +99,7 @@ class Record: # handle gid if attrib_name == 'gid': print " gid:" - print GID(attrib).dump_string(8, dump_parents) + print GID(string=attrib).dump_string(8, dump_parents) elif attrib_name in ['date created', 'last updated']: print " %s: %s" % (attrib_name, self.date_repr(attrib_name)) else: