Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Mikhail Podgurskiy
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
what do you mean by in-place?
I tried to do something like:
def step1(self):
if ...:
but the transition has not happened yet so the state is not right at the time it happens
Mikhail Podgurskiy
In the views.py where you call step1
Arthur Rio
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
Glad to help )
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
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
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
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.
oh, I'm so sorry for bothering you guys. Thanks!
could you explain why it's a bad idea ?
Mikhail Podgurskiy
It's limited by transitions witho
ut arguments. And - it's limited by single transition on save.
And there is no easy way to overcame it.
Attila Szabo
Hi! I have some problem with the graph_transitions management command. I have a transition which uses the RETURN_VALUE function for providing multiple target states for a transition (it's based on a condition). When I would like to use the management command it fails with the following error.
File "/Users/szaboat/service/virtualenv/lib/python2.7/site-packages/django_fsm/management/commands/graph_transitions.py", line 86, in generate_dot
    subgraph.node(name, label=label, shape='doublecircle')
  File "/Users/szaboat/service/virtualenv/lib/python2.7/site-packages/graphviz/dot.py", line 104, in node
    attributes = self.attributes(label, attrs, _attributes)
  File "/Users/szaboat/service/virtualenv/lib/python2.7/site-packages/graphviz/lang.py", line 91, in attributes
    result = ['label=%s' % quote(label)]
  File "/Users/szaboat/service/virtualenv/lib/python2.7/site-packages/graphviz/lang.py", line 44, in quote
    if html(identifier):
TypeError: expected string or buffer
is it a known issue?
Mikhail Podgurskiy
Yeah. I didn't check graph_transitions for a while
Actually most of graph transitions code not written by me but contributed to the repo
So, pull requests are welcome )
Attila Szabo
ok :) first we will try to make the code clean and readable then we should not have to use the graphing :)
Hi, it is possible to change the status by a url?
I would like to change the status after redirection to a given url.
django-fsm is compatible with python 3.6.x?
Lucas Huang
hey guys, i have a question. there is a django in my project where contains a fsmfield, then i added a boolean field. everything went okay until I update that boolean field, got error like this
AttributeError: Direct state modification is not allowed
i simply update that field:
obj.boolean_field = False
but I didn't modify the fsmfield. how come I got that error?
François GUÉRIN
Hi guys
I'ld like to know if it is possible to give the current request to a transition ?