这是我试图用我的代码完成的结构。我想使用registry.filter和registry.action来加载我正在构建的应用程序的过滤器和操作。我知道我可以将它们分成两个不同的装饰器。
def registry():
def filter(*expected_args):
def decorator(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
return decorator
def filter(*expected_args):
def decorator(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
return decorator
@registry.filter({
})
def my_filter():
print "Hello World!"
@registry.action({
})
def my_action():
print "Hello World!"
if __name__ == "__main__":
my_filter()
my_action()
每当我运行我的代码时,都会收到此错误:
Traceback (most recent call last):
File "/Users/chris/Documents/Content-Management/registry.py", line 19, in <module>
@registry.filter({
AttributeError: 'function' object has no attribute 'filter'