Skip to content

Calling the parent method for a transition #13

@bors-ltd

Description

@bors-ltd

Hi,

With the following use case:

class Parent(xworkflows.WorkflowEnabled):
    @xworkflows.transition()
    def accept(self):
        # Default behaviour


class Child(Parent):
    @xworkflows.transition()
    def accept(self):
        if child_condition:
            # Child behaviour

        return super(Child, self).accept()

child = Child()
child.accept()

If child_condition is not met, it calls the original accept method. But it leads to two "accept" transitions in the log, the second one being already from the "accepted" state, although it's not allowed by the workflow.

I found out I can access the undecorated Parent.accept method via return super(Child, self).accept.func().

The real issue happened on a Django model with django-xworkflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions