Open turicas opened 11 years ago
Maybe (but probably not) we can use decorators instead of inheritance to specify that a class is a worker, but probably a better approach is to use inheritance since we can add helper methods to Worker
.
We could use both solutions. Use inheritance and the decorator which we have done together.
def Worker(requires):
def Worker2(worker_function):
class WorkerClass(object):
def process(self, document):
document['passou'] = 'por aqui'
return worker_function(document)
WorkerClass.requires = requires
return WorkerClass
return Worker2
@Worker(requires=['teste'])
def Teste(document):
return document
Should not be needed to specify a
__all__
in the workers module: Broker should inspect the module for classes that inherit frompypelinin.Worker
.