python-simple-workflow icon indicating copy to clipboard operation
python-simple-workflow copied to clipboard

querysets.WorkflowTypeQuerySet.filter() should behave like a class method

Open ggreg opened this issue 12 years ago • 2 comments

If we filter by domain we should not have to instanciate WorkflowTypeQuerySet with a Domain in argument.

ggreg avatar Apr 03 '13 18:04 ggreg

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()]

oleiade avatar Apr 04 '13 08:04 oleiade

If domain_name is a filtering key we should allow to instanciate a queryset without a domain.

ggreg avatar Apr 04 '13 08:04 ggreg