-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple xwf_models.Workflow #9
Comments
Glad you like the app! You have an interesting problem, which indeed would require lots of hacks to work with the current version of xworkflows (and django_xworkflows). The main issue I'd see with your approach is the fact that the chosen workflow depends on an instance field ; but XWorkflows uses metaclasses to alter various methods of the class depending of the attached workflow... (this is one of the reasons for your code not working). A simple example of those issues would be: The simplest way I'd see would be to build a single The only change needed to xworkflows would be to set the initial class MyObject(WorkflowEnabled):
def _xworkflow_initial_state(self, field):
if self.foo:
return MyWorkflow.states.branch_a
else:
return MyWorkflow.states.branch_b |
Thanks for your answer. You're absolutely right for the initial state issue. Moreover it could be mandatory to share the same initial state, for all of the instances. Also, the transitions could be different from an instance to another. Say instA could have BTW, if I understand your answer :
Regards, |
That would be the main idea, yes. But I think the Feel free to ping me if you need help on that topic ! |
Hello, I quickly tried to test the idea of _xworflow_initial_state here ouhouhsami/xworkflows@745193a Tests pass, but the design is not very clean. Also, for my own use case, as long as I have distinct initial states and disjoint transitions, it seems to do the trick, but I have to test. |
Hello,
Great app ... thanks !
I'm looking for a way to have workflow "instance based". I have multiple instance of my model, say InstA and InstB, and I would like to assign them different workflows, based on, for example instance attribute (for instance the foo boolean field in my example below).
I tried this, but it doesn't work :
Is my problem clear, and do you thing django_xworkflows could face this use case ?
Regards,
The text was updated successfully, but these errors were encountered: