It worked OK, and I realized I had another relation with the same setup:

(class +Awords +Entity)
(rel words (+Blob))
(rel counts (+Blob))

(dm put> (Key Val)
   (put!> This Key T)
   (out (blob This Key)
      (prinl Val)))

The above works but I wanted to follow your advice on this one too, so
I changed it to:

(dm put> (Key Val)
   (super This Key T)
   (out (blob This Key)
      (prinl Val)))

However, I'm getting:
!? (has> (meta This Var) Val (get This Var))
has> -- Bad message

When I run the code which is using the above like this:

(let Awords (new! '(+Awords))
  (put> Awords 'words Words)
  (put> Awords 'counts (mapcar val Words))
  (put> A 'words Awords))

Any ides on why the "super" version isn't working out this time?

/Henrik


On Wed, Sep 16, 2009 at 7:55 AM, Alexander Burger <a...@software-lab.de> wro=
te:
> Hi Henrik,
>
>> (class +Article +Entity)
>> (rel aid =A0 =A0 =A0 (+Key +Number))
>> (rel title =A0 =A0 (+String))
>> (rel type =A0 =A0 =A0(+String))
>> (rel htmlUrl =A0 (+Key +String))
>> (rel body =A0 =A0 =A0(+Blob))
>>
>> (dm put> (Key Val)
>> =A0 =A0(if (=3D Key 'body)
>> =A0 =A0 =A0 (prog
>> =A0 =A0 =A0 =A0 =A0(put!> This 'body T)
>> =A0 =A0 =A0 =A0 =A0(out (blob This 'body)
>> =A0 =A0 =A0 =A0 =A0 =A0 (prinl Val)))
>> =A0 =A0 =A0 (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:
>
> =A0 (dm put> (Key Val)
> =A0 =A0 =A0(ifn (=3D=3D Key 'body)
> =A0 =A0 =A0 =A0 (super Key Val)
> =A0 =A0 =A0 =A0 (super 'body T)
> =A0 =A0 =A0 =A0 (out (blob This 'body)
> =A0 =A0 =A0 =A0 =A0 =A0(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!> ()
>> =A0 =A0(call 'rm (blob This 'body))
>> =A0 =A0(put!> This 'body NIL)
>> =A0 =A0(super))
>
> 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.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe
>
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to