def configure_custom(self, config): """Configure an object with a user-supplied factory.""" c = config.pop('()') if not callable(c): c = self.resolve(c) props = config.pop('.', None) # Check for valid identifiers kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) result = c(**kwargs) if props: for name, value in props.items(): setattr(result, name, value) return result
def configure_custom(self, config): """Configure an object with a user-supplied factory.""" c = config.pop('()') if not callable(c): c = self.resolve(c) props = config.pop('.', None) # Check for valid identifiers kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) result = c(**kwargs) if props: for name, value in props.items(): setattr(result, name, value) return result
def _resolve_queue(q): if not isinstance(q, ConvertingDict): return q if '__resolved_value__' in q: return q['__resolved_value__'] cname = q.pop('class') klass = q.configurator.resolve(cname) props = q.pop('.', None) or {} kwargs = {k: q[k] for k in q if valid_ident(k)} result = klass(**kwargs) for name, value in props.items(): setattr(result, name, value) q['__resolved_value__'] = result return result