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
ut arguments. And - it's limited by single transition on save.
And there is no easy way to overcame it.
Attila Szabo
@szaboat
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
@kmmbvnr
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
@szaboat
ok :) first we will try to make the code clean and readable then we should not have to use the graphing :)
maltitco
@maltitco
Hi, it is possible to change the status by a url?
I would like to change the status after redirection to a given url.
maltitco
@maltitco
django-fsm is compatible with python 3.6.x?
Lucas Huang
@Lucashuang0802
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
obj.save()
but I didn't modify the fsmfield. how come I got that error?
François GUÉRIN
@frague59
Hi guys