Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Arthur Rio
@arthurio
Hi Mikhail, this last bug is kinda blocking for us, anyway I could help finding the root cause? Do you have any pointer?
Mikhail Podgurskiy
@kmmbvnr
You can just use 3 different separate methods
Arthur Rio
@arthurio
That's our current workaround
But it means having an if statement to make the right call based on the current state
Mikhail Podgurskiy
@kmmbvnr
Or stop using signals at all. In most cases it is a bad practice. I actually never used it with django-fsm for 5 years
Arthur Rio
@arthurio
I used it to skip a transition for a special case...
on the signal I was automatically calling the "submit" if something didn't need review
Mikhail Podgurskiy
@kmmbvnr
Skip transition with a signal? Yeah That's sounds ugly
Too unexplicit and magical.
Why just not call next transition method in-place with previous one?
Arthur Rio
@arthurio
what do you mean by in-place?
I tried to do something like:
@transition(...)
def step1(self):
if ...:
skip_to_step3()
but the transition has not happened yet so the state is not right at the time it happens
Mikhail Podgurskiy
@kmmbvnr
In the views.py where you call step1
Arthur Rio
@arthurio
Because we have different state_machines extending a common class. Some instances have different behaviors... Anyway I see your point and I think if we refactor a little bit I could make the call more explicit and not use the signals
thanks a lot for your quick feedback :)
Mikhail Podgurskiy
@kmmbvnr
Glad to help )
Emil
@emil-balashov
Hi guys,
I think I've got a bug when I try to use FSMTransitionMixin for saving an object with related fields in the Admin. Basically it works fine but if I add some code to a method with transaction it doesn't, because FSMTransitionMixin override save_model method, but saving of related objects runs after save_model, so those new related objects don't exist on the transaction step. Is it the bug or have I misunderstood? I've created a mixin which works fine but with double saving.
class AdminFSMTransitionMixin(FSMTransitionMixin):
    def save_related(self, request, form, formsets, change):
        super(AdminFSMTransitionMixin, self).save_related(request, form, formsets, change)

        # Apply transactions
        if form.is_valid():
            fsm_field, transition = self._get_requested_transition(request)
            if transition:
                self._do_transition(transition, request, form.instance, form, fsm_field)
                self.save_model(request, form.instance, form, change)

    def save_model(self, request, obj, form, change):
        # Saving without transactions
        super(FSMTransitionMixin, self).save_model(request, obj, form, change)
Johannes Hoppe
@codingjoe
Just to make sure, that I understood you correctly. You want to save the instance and make a transition? The transition should be atomic. Thus I’d advice you to save in advance and execute the transition. Otherwise you cant ensure that you local instance actually represents the instance saved to the database.
Mikhail Podgurskiy
@kmmbvnr
I don't understand, what issue is? Is transition happens or not?
And what issues you have with transactions? Yeah probably there is no optimistic locking for saving related.
Mikhail Podgurskiy
@kmmbvnr
Oh. That's about another project. Django-fsm-admin. Please ask the project authors about it
I think using django-fsm-admin itself is a bad idea anyway.
Emil
@emil-balashov
oh, I'm so sorry for bothering you guys. Thanks!
could you explain why it's a bad idea ?
Mikhail Podgurskiy
@kmmbvnr
It's limited by transitions witho