action_base.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:django-account-actions 作者: erudit 项目源码 文件源码
def __new__(cls, name, bases, attrs):
        super_new = super(AccountActionMetaclass, cls).__new__
        parents = [base for base in bases if isinstance(base, AccountActionMetaclass)]
        if not parents:
            # We stop here if we are considering AccountActionBase and not
            # one of its subclasses
            return super_new(cls, name, bases, attrs)
        new_action = super_new(cls, name, bases, attrs)

        # Performs some checks

        action_name = getattr(new_action, 'name', None)
        if action_name is None or not isinstance(action_name, six.string_types):
            raise ImproperlyConfigured('The "name" attribute must be a string')

        execute_method = getattr(new_action, 'execute', None)
        if execute_method is None or \
                not (inspect.ismethod(execute_method) or inspect.isfunction(execute_method)):
            raise ImproperlyConfigured('The "execute" method must be configured')

        return new_action
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号