Wasn't it possible to do getattr(self, 'layer') ?