materializing a MaCommitLogRecord
Dave Woodward
davewoodward at promedmedical.net
Mon Jun 14 20:01:42 UTC 2010
On 6/14/10 3:01 PM, Chris Muller wrote:
>> Only because a feature requested for my app is "the ability to audit who
>> changed what... just in case." It doesn't need to be an end-user accessible
>> feature, and it won't be used often. Instead of me building something new I
>> realized that Magma has these commit records in the db already... so I'm
>> thinking I can just do something simple like record which commit numbers a
>> user is responsible for and then if I need to I can go back later and
>> extract the needed information from that commit.
>>
> If this is for Sarb'Ox then I think you made the right choice;
> employing the database-level auditing information, rather putting it
> in the app. Plus, your approach not only captures the auditry about
> the current state of all objects, but their entire historical updates
> as well. Excellent.
>
We're a private company... but yeah, its basically a CYA feature.
>
>> Nevermind, I figured it out. I need to use MagmaSession
>> newCommitLogSerializer to materialize the graph in a commit record, not the
>> serializer from the current session.
>>
> Yep, you found it, good hunting. I don't know whether you'd found the
> "Magma Tools" package but, in there, you'll find a tool called
> "MagmaBufferController" which materializes CommitPackages in this
> manner as well. With the tool you can essentially browse the
> persistent model without materializing any domain instances..
>
>
>> However... now I'm not really sure what to make of the contents of the
>> buffers inside the serialized buffer of the commit package. I don't see any
>> domain objects in there, just an array of oids, the timestamp and something
>> else that I can't seem to materialize.
>>
> You could:
>
> mySession serializer independentCopy materializeObject:
> theCommitPackage objects.
>
> #materializeObject: is a private method but given your new
> requirements and ideas, you would want a nice, small API for accessing
> the objects out of a CommitLogRecord in this manner...
>
> But, allow me to suggest that this may not be necessary. You just
> want to see the "contents" of the objects, you aren't as interested in
> executing their behaviors, right?
>
Yep.
> If so, rather than trying to materialize an old portion of the model,
> I would try that MagmaBufferController, et al, to do this job. With
> that tool, you get not only the *shape* of the object model, but also
> easy-access to type, numeric, and string contents of objects, not to
> mention the audit information as well, all from one single object
> (MagmaBufferFacade).
>
Ok, I loaded up the Magma Tools package and played with the
MagmaBufferController. This is pretty cool. I figured out how to
browse the contents of the buffers for a commit using the
"referencedBuffers" method and inspectors. This is good enough for now.
I realize that its designed for use with Maui... and Maui doesn't load
in Pharo (I know its an old project). Maybe I'll see if there is a way
to subclass Pharo's Inspector to make a primitive UI for the Buffer
Controller or something.
Or maybe I'll just load up the DB with my domain in a Squeak image where
all of these tools work :). I've watched a video of Maui in action and
its pretty cool!
> Attempting to materialize a single CommitPackage gives you a "portion"
> of an old-version of the model. It can be done, but it's a bit more
> work..
>
> - Chris
>
Thanks again for your help!
--
Dave Woodward
More information about the Magma
mailing list