Hopbot log for 2008-03-01 - Helma IRC channel: #helma on irc.freenode.net

2008-03-01:

[8:46] <bslivka> Okay so here's a point of confusion for me- and perhaps this is better suited to the mailing list-
[8:46] <bslivka> I've got a helma app using the built in DB
[8:47] <bslivka> For a collection- spectra, attached to root, I have specified in root's type.properties
[8:47] <bslivka> spectra.accessname = name
[8:48] <bslivka> Now for each object in the collection, the url it can be accessed from is taken from the name property
[8:48] <bslivka> so for instance, the first object has this url : /spectradb/spectra/1%09PANTONE%09032%09U/
[8:49] <bslivka> However, href() for the object returns /spectradb/spectra/3/
[8:49] <bslivka> which is incorrect
[8:50] <bslivka> For another project I've worked around this by simply overwriting the href() function for the object in question with my own
[8:50] <bslivka> But I should be able to specify _name to equal something in the spectra prototype's type.properties right?
[8:51] <zumbrunn> I believe the same problem happens for _children collections as well
[8:51] <zumbrunn> that's why I need to add an additional line to the type.properties containing just "name"
[8:52] <zumbrunn> but I'm not sure how that will work for your spectra collection
[8:52] <bslivka> Kablam, it worked
[8:53] <bslivka> Well well then, that was simple enough
[8:53] <zumbrunn> :-)
[8:53] <bslivka> seems like the sort of pitfall that should be documented somewhere though.
[8:53] <bslivka> But I'm not sure where the best place to document this is
[8:54] <bslivka> Thanks for your help though, chris
[8:54] <zumbrunn> we would need good reference type docs for everything related to type.properties
[9:01] <bslivka> I've got one more question, though it's kinda stupid.
[9:01] <bslivka> spectra is a hopobject with a property named "samples", samples is an array.
[9:02] <bslivka> onPersist() is defined as this.serialSamples=this.samples.toJSON();
[9:02] <bslivka> onInit() in turn is defined as this.samples=this.serialSamples.parseJSON();
[9:03] <bslivka> this is basically so that the array object actually gets persisted.
[9:03] <bslivka> when it's persisted, the samples property simply vaprizes, as one might expect
[9:04] <bslivka> which my hopobject is initialized, the serialSamples property sticks around.
[9:04] <bslivka> Which is not necessarily undesirable, but it's a bit untidy
[9:04] <bslivka> That's why it's a stupid question, how would I safely dispose of that property?
[9:05] <bslivka> I suspect that if I put delete serialSamples in onInit it would setoff an infinite loop
[9:08] <bslivka> either that, or serialSamples would simply spring back into existance when onPersist is called immediately after the "delete" command
[9:09] <bslivka> I hope what I'm trying to achieve is clear, though admittedly it might not be.
[9:10] <bslivka> a simpler way to put it might be "What's the cleanest way to persist hopobjects with object properties"
[9:20] <zumbrunn> bslivka, I don't know yet
[9:21] <zumbrunn> I'm currently doing what you are doing and thought about the same question
[9:22] <zumbrunn> http://code.google.com/p/e4xd/source/browse/trunk/objectengine/Mocha/handlers.js
[9:23] <zumbrunn> my onInit and onPersist handlers leave me with ghost properties with a _ suffix
[9:24] <zumbrunn> ideal would be a trick to serialize the properties to the same name
[9:25] <zumbrunn> which would work in my case, since I can tell what I need to unserialize based on the property names
[9:26] <zumbrunn> but like you said, the trick would be how to prevent an infinite loop
[9:26] <zumbrunn> I just haven't tested this yet, so there might be a way
[9:26] <bslivka> I suppose from a relational model perspective- the "correct" thing to do is rather than have an array, have a collection
[9:26] <bslivka> but it seems a bit wasteful to have a whole hopobject devoted to a single number
[9:27] <zumbrunn> yes, that would be the "helma way"
[9:27] <zumbrunn> which is why this problem isn't one everybody has in the helma community
[9:28] <zumbrunn> a single number?
[9:28] <bslivka> my samples array-
[9:28] <zumbrunn> helma serializes numbers automatically anyway
[9:28] <bslivka> it's just an array of numbers
[9:28] <zumbrunn> oh, array of numbers, right
[9:29] <bslivka> To have it as a collection would entail an XML file for each number
[9:29] <bslivka> which seems a bit absurd doesn't it?
[9:29] <zumbrunn> definitely
[9:30] <bslivka> Nevertheless, the solution may be to temporarily disable automatic persistance during onInit, I think
[9:30] <bslivka> But I don't know if there's a way to do that
[9:31] <bslivka> I vaguely remember something to that extent somewhere but I may be imagining it
[9:39] <zumbrunn> my babbling here was kind of related to that:
[9:39] <zumbrunn> http://helma.org/pipermail/helma-dev/2007-November/003917.html

 

 

In the channel now:

Logs by date: