def __init__(self, config): BlogConfigUser.__init__(self, config) # Register this extension in the appropriate places thismod = sys.modules[__name__] attr_tmpl = '{}_' mixin_tmpl = '{}_mixin' for etype in extension_types: # Check for methods that extend a known attribute if any( item for item in prefixed_items(dir(self), attr_tmpl.format(etype)) if not item.endswith('mixin') ): extension_map[etype].append(self) # Check for extensions that declare mixins mixin = getattr(self, mixin_tmpl.format(etype), None) if mixin: mixin_klass = getattr(thismod, '%sMixin' % etype.capitalize()) mixin.extension_type = etype extend_attributes(mixin) oldcls = extension_types[etype] if issubclass(oldcls, mixin_klass): bases = (mixin,) + oldcls.__bases__ else: bases = (mixin, oldcls) extcls = wraps_class(oldcls)(type(oldcls)('Extended', bases, {})) extension_types[etype] = extcls # Allow for post-init processing in subclasses self.post_init()
def __init__(self, config): BlogConfigUser.__init__(self, config) # Register this extension in the appropriate places thismod = sys.modules[__name__] attr_tmpl = '{}_' mixin_tmpl = '{}_mixin' for etype in extension_types: # Check for methods that extend a known attribute if any(item for item in prefixed_items(dir(self), attr_tmpl.format(etype)) if not item.endswith('mixin')): extension_map[etype].append(self) # Check for extensions that declare mixins mixin = getattr(self, mixin_tmpl.format(etype), None) if mixin: mixin_klass = getattr(thismod, '%sMixin' % etype.capitalize()) mixin.extension_type = etype extend_attributes(mixin) oldcls = extension_types[etype] if issubclass(oldcls, mixin_klass): bases = (mixin, ) + oldcls.__bases__ else: bases = (mixin, oldcls) extcls = wraps_class(oldcls)(type(oldcls)('Extended', bases, {})) extension_types[etype] = extcls # Allow for post-init processing in subclasses self.post_init()
def __init__(self, config, opts, args): BlogConfigUser.__init__(self, config) self.opts = opts self.args = args