possibility of attribute error in resorce_from_data

It now checks `hasattr` before doing `getattr`