Hi, all.. I am finally ready to work on the persistence end of my project. I am having a little bit of an issue, though.. I have very simple set of models: Customers Orders LineItems more.. The Customer has a variable called ‘orders’ which is just an OrderedCollection of Orders. The trick is, this is an SMS bot, so the order has a StateMachine (SsStateMachine) that, after it receives an SMS.. it processes it, and moves (or doesn’t) along in state. the problem I have is, when I save the customer, I need to save the orders first (I got an error stating this). When I try to save the order, I get the following error: 'An ActiveRecord can not reference any sub instances of instruction stream. Make sure you are not saving blocks. ‘ This looks like it’s happening at the point where it is trying to save the StateMachine.. Here is the full error.. Thanks!: Context(InstructionStream)>>sandstoneDeepCopyVisits: BlockClosure(Object)>>sandstoneDeepCopyVisits: SsState(Object)>>sandstoneDeepCopyVisits: SsStateMachine(Object)>>sandstoneDeepCopyVisits: Order(Object)>>sandstoneDeepCopyVisits: Order(SDActiveRecord)>>sandstoneDeepCopy SDFileStore>>storeObject: [ self validate. (isFirstSave := isNew) ifTrue: [ self onBeforeFirstSave ]. self onBeforeSave. isFirstSave ifTrue: [ Store storeObject: self ] ifFalse: [ Store updateObject: self ]. isFirstSave ifTrue: [ self onAfterFirstSave ]. self onAfterSave. self ] in Order(SDActiveRecord)>>save [ self enter. aBlock value ] in Monitor>>critical: BlockClosure>>ensure: Monitor>>critical: Order(SDActiveRecord)>>critical: Order(SDActiveRecord)>>save UndefinedObject>>DoIt OpalCompiler>>evaluate RubSmalltalkEditor>>evaluate:andDo: RubSmalltalkEditor>>highlightEvaluateAndDo: [ textMorph textArea editor highlightEvaluateAndDo: ann action. textMorph shoutStyler style: textMorph text ] in [ textMorph textArea handleEdit: [ textMorph textArea editor highlightEvaluateAndDo: ann action. textMorph shoutStyler style: textMorph text ] ] in GLMMorphicPharoScriptRenderer(GLMMorphicPharoCodeRenderer)>>actOnHighlightAndEvaluate: RubEditingArea(RubAbstractTextArea)>>handleEdit: [ textMorph textArea handleEdit: [ textMorph textArea editor highlightEvaluateAndDo: ann action. textMorph shoutStyler style: textMorph text ] ] in GLMMorphicPharoScriptRenderer(GLMMorphicPharoCodeRenderer)>>actOnHighlightAndEvaluate: WorldState>>runStepMethodsIn: WorldMorph>>runStepMethods WorldState>>doOneCycleNowFor: WorldState>>doOneCycleFor: WorldMorph>>doOneCycle WorldMorph class>>doOneCycle [ [ WorldMorph doOneCycle. Processor yield. false ] whileFalse: [ ] ] in MorphicUIManager>>spawnNewProcess [ self value. Processor terminateActive ] in BlockClosure>>newProcess ---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
2017-07-11 2:16 GMT+02:00 sergio ruiz <[hidden email]>:
I think Sandstone do not support block serialization. To fix it in your application you need convert block to some valuable objects like message send. If you are not using blocks directly then the reason could be related to sorted collection which is usually created with sorted block. Here you also need convert sort block to message send with two args. |
i’m not sure i understand what is going on.. it seems to be hung up trying to save SsStateMachine.. I am setting up the state machine on initialization using (where state machine is an instance variable): setupStatemachine | stCustomerIncomplete stNoImages stImagesAttached stSizeSelected stOrderComplete | statemachine := SsStateMachine new. stCustomerIncomplete := (statemachine addStateNamed: #stateCustomerIncomplete) when: #toNext guarded: [ customerComplete isNotNil ] to: #stateNoImages. and on and on with more states.. ---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
2017-07-11 16:25 GMT+02:00 sergio ruiz <[hidden email]>:
So to be able serialize such object you need to replace #guarded block with message send like: Maybe there is the way how to make blocks serialyzable because Fuel support it. But I never use sandstoneDB and it can use some different library. |
Oh! i forgot to mention.. this method belongs to Order.. so that part is working just fine.. On July 11, 2017 at 10:41:20 AM, Denis Kudriashov ([hidden email]) wrote:
---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
On 07/11/2017 10:05 AM, sergio ruiz wrote:
> Oh! i forgot to mention.. this method belongs to Order.. > > so that part is working just fine.. Doesn't matter where the method is, your state machine clearly has blocks stored as instance variables and you're trying to save the state machine as part of the Order; SandstoneDb doesn't support saving blocks. I'd try what Dennis Suggested and store message sends rather than blocks for the guarded method, then it might save fine. Inspect the state machine, any use of blocks has to be removed/changed to message sends in order for it to be persistable by SandstoneDb. -- Ramon Leon http://onsmalltalk.com |
OH! okay.. this is making sense now.. I think i just had to look at it for a minute.. Let me try that .. Thanks! On July 11, 2017 at 2:53:35 PM, Ramon Leon ([hidden email]) wrote:
---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
In reply to this post by Ramon Leon-5
Okay, got it.. I tried this.. but what happens when i change this to message sends (it does save) is that the state machine no longer works. The reason for this being that when he state machine is initialized, it’s initialized with the result of the message send, I think this needs to be a block so that it is evaluate as the state machine moves through state.. I think i am gonna take a quick look at Magma.. and see if this will suit my needs.. Thanks! On July 11, 2017 at 2:53:35 PM, Ramon Leon ([hidden email]) wrote:
---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
2017-07-13 14:44 GMT+02:00 sergio ruiz <[hidden email]>: I tried this.. but what happens when i change this to message sends (it does save) is that the state machine no longer works. The reason for this being that when he state machine is initialized, it’s initialized with the result of the message send, I think this needs to be a block so that it is evaluate as the state machine moves through state.. Try to debug what happens when you pass message send instead of block. Maybe StateMachine code perform some explicit check isBlockClosure. |
Hmm.. let me try that.. I think it might be wiser at this point to find a more suitable persistence model. i was just looking for something that would work for a week or so until i needed to make this production ready.. looking at how this project is moving now (it’s done, and ready to start doing real world work).. i think i just need to settle on what is going to be the final production datastore and set that up.. thanks! On July 13, 2017 at 10:46:21 AM, Denis Kudriashov ([hidden email]) wrote:
---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
In reply to this post by Denis Kudriashov
What is happening is that when the StateMachine gets set up in order initialization, the guarded condition is set.. when you pass a MessageSend to it, it just evaluates to the value of that message send on initialization.. When you pass a block to it, the block is evaluated every time the call is made.. On July 13, 2017 at 10:46:21 AM, Denis Kudriashov ([hidden email]) wrote:
---- peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101 signature.asc (852 bytes) Download Attachment |
Free forum by Nabble | Edit this page |