Spaces:
Configuration error
Configuration error
| from .utils import public_names | |
| class ObjectService: | |
| def __init__(self, collections): self._collections=collections | |
| def to_record(obj): | |
| r={} | |
| for n in public_names(obj): | |
| try: v=getattr(obj,n) | |
| except Exception: continue | |
| if callable(v): continue | |
| try: r[n]=v if isinstance(v,(str,int,float,bool)) or v is None else str(v) | |
| except Exception: r[n]=None | |
| return r | |
| def collection_records(self,name): | |
| out=[] | |
| for key,obj in self._collections.items(name): | |
| row={"Name":key,"ObjectType":name}; row.update(self.to_record(obj)); out.append(row) | |
| return out | |