> (class +Article +Entity)
> (rel aid (+Key +Number))
> (rel title (+String))
> (rel type (+String))
> (rel htmlUrl (+Key +String))
> (rel body (+Blob))
> (dm put> (Key Val)
> (if (= Key 'body)
> (put!> This 'body T)
> (out (blob This 'body)
> (prinl Val)))
> (super Key Val)))
I didn't try this code, and have no direct explanation why you get an
error upon re-import, but I see a different problem:
It is not good to nest 'put!>' within 'put>'. 'put!>' builds its own
transaction with 'dbSync' and 'commit'. This means, that you get a
preliminary 'commit', which will unlock the database too early.
So the 'put!>' above should at least be a simple 'put>'. Then
we might simply use 'super' instead:
(dm put> (Key Val)
(ifn (== Key 'body)
(super Key Val)
(super 'body T)
(out (blob This 'body)
(prinl Val) ) ) )
As usual, this 'put>' must run in a transaction (surrounded by 'dbSync'
and 'commit'), of course.
I don't know if this solves the original problem though.
The same situation ('put!>' inside 'lose!>') we have here:
> (dm lose!> ()
> (call 'rm (blob This 'body))
> (put!> This 'body NIL)
In fact, I never directly remove blobs, and rely on the nightly garbage
collection to have them cleaned up. So the above 'lose!>' method might
simply be omitted.