def include(urllist_name): if isinstance(urllist_name, basestring): urllist = import_entity(urllist_name) return Urls(*urllist) elif isinstance(urllist_name, tuple): return urllist_name else: raise TypeError("A tuple is expected!")
def __init_middlware(self, wrappers): middleware = list() for wrapper, wopts in wrappers: options = self.options.copy() options.update(wrappers.default_options) options.update(wopts) if isinstance(wrapper, str): wrapper = import_entity(wrapper) middleware.append(wrapper(options)) return middleware
def import_if_needed(pattern, call, kwargs): if isinstance(call, basestring): call = import_entity(call) return (pattern, call, kwargs)