-
I have a class that inherites statemachine and has no states and no transitions, all are defined in the children classes. The problem is that from version 1.0 it's mandatory to have transitions and states. Can you reverse it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @galhyt, thanks for reporting this. Can you provide a context of how you're using this intermediate class, for my education? I want to understand the use case. I'll think about how to suppress the validation on classes that do not have any state and transition as an "abstract" class. AlternativesWhile we don't have this new release, I think that you can alternatively use two options. Consider this class as the one that currently is your base class using inheritance, and It holds the custom behavior you wanna share: class MyCustomBehavior:
def on_enter_state(self):
pass MixinsYou can use this class as a mixin (multiple inheritances): class MyConcreteStateMachine(StateMachine, MyCustomBehavior):
... ObserversYou can use this class as an observer: class MyConcreteStateMachine(StateMachine):
...
sm = MyConcreteStateMachine()
sm.add_observer(MyCustomBehavior()) Let me know if one of these alternatives works for you. Best regards! |
Beta Was this translation helpful? Give feedback.
-
Thank you for your kind reply, unfortunately only now I notice it.
I saw you've already added support for this type of class, so tnx again.
My use case is as follows:
1. We use the state machine to coordinate actions on aws ec2
filesystems. Each action includes steps both in the cloud and the machine
filesystem.
2. There are 3 types of actions: add_disk, extend_disk & remove_disk.
For example, adding new disk requires first creating it on aws then
attaching to the ec2 instance (the machine) and finally add it to the
filesystem in the machine.
3. There is shared implementation for all 3 types so we have for them a
base class called Action that inherites statemachine class.
That's on a nutshell, hope it makes sense.
Best regards,
Gal
…On Wed, 8 Feb 2023 at 17:14, Fernando Macedo ***@***.***> wrote:
Hi @galhyt <https://github.com/galhyt>, thanks for reporting this.
Can you provide a context of how you're using this intermediate class, for
my education? I want to understand the use case.
I'll think about how to suppress the validation on classes that do not
have any state and transition as an "abstract" class.
—
Reply to this email directly, view it on GitHub
<#344 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXWKLWH2ITZH7WKQSMEBX3WWOZ6FANCNFSM6AAAAAAULR6DNU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
.com>
|
Beta Was this translation helpful? Give feedback.
Hi @galhyt, thanks for reporting this.
Can you provide a context of how you're using this intermediate class, for my education? I want to understand the use case.
I'll think about how to suppress the validation on classes that do not have any state and transition as an "abstract" class.
Alternatives
While we don't have this new release, I think that you can alternatively use two options.
Consider this class as the one that currently is your base class using inheritance, and It holds the custom behavior you wanna share:
Mixins
You can use this class as a mixin (multiple inheritances):