python-simple-workflow
python-simple-workflow copied to clipboard
querysets.WorkflowTypeQuerySet.filter() should behave like a class method
If we filter by domain we should not have to instanciate WorkflowTypeQuerySet with a Domain in argument.
How would the method prototype would look like then, would domain_name become mandatory?
Plus, I'm very aware of class methods usage, but queryset depends on their instance connection attribute to go fetch data from amazon, how would it be handled without self instance reference?
current method:
def filter(self, domain_name=None, registration_status=REGISTERED, name=None):
"""Filters workflows based of their status, and/or name"""
def get_workflows():
response = {'nextPageToken': None}
while 'nextPageToken' in response:
response = self.connection.list_workflow_types(
domain_name,
registration_status,
name=name,
next_page_token=response['nextPageToken']
)
for workflow in response['typeInfos']:
yield workflow
# As WorkflowTypeQuery has to be built against a specific domain
# name, domain filter is disposable, but not mandatory.
domain_name = domain_name or self.domain.name
return [self.to_WorkflowType(wf) for wf in get_workflows()]
If domain_name is a filtering key we should allow to instanciate a queryset without a domain.