[Helma-user] accessing type.properties
Breton Slivka
Breton.Slivka at ngv.vic.gov.au
Thu Jul 3 05:04:18 CEST 2008
Okay, to be more serious. I was actually quite stoked by your initial
email. Why? Because I didn't know you could programatically read
type.properties at all! You know what else you can do? You can set it
programatically. I immediately set out to write an example of replacing
type.properties with an Object Literal in javascript. That's as follows:
ArtworkType.js:
jsonType(
"Artwork",
{
"_id" : "ARTWORK_ID",
"_db" : GlobalDatabase, // a global variable set
earlier.
"artist": "ARTIST_ID",
"year": "YEAR",
"title": "TITLE
});
Global.js:
function jsonType(prototypename, json) {
var typeproperties =
app.getPrototype(prototypename).getTypeProperties();
var i;
for(i in json) {
typeproperties.setProperty(i, json[i]);
}
return jsonType; //This enables some nice chaining.
}
>From here it's not that much of a leap to make the original "json"
object an array like so:
ArtworkType = [
{"_id" : "ARTWORK_ID"},
{"_db" : GlobalDatabase}, // a global variable set
earlier.
{"artist": "ARTIST_ID"},
{"year": "YEAR"},
{"title": "TITLE}
]
Then modify the jsonType function accordingly:
jsonType("Artwork", ArtworkType)
And bam, you've got type.properties as a literal, throw away the
type.properties file.
And not only that, but you can then go on to query the ArtworkType
object to generate forms, in the order that you want, and everything is
specified in only one place.
-----Original Message-----
From: helma-user-bounces at helma.org [mailto:helma-user-bounces at helma.org]
On Behalf Of Joshua Paine
Sent: Thursday, 3 July 2008 12:56 PM
To: Helma User Mailing List
Subject: Re: [Helma-user] accessing type.properties
Breton Slivka wrote:
> In the spirit of idea generation, here's a very silly solution:
Maybe I should make it an explicit design goal that someone reading the
code should not have to consult wikipedia. :-)
> Once you convert a factoradic into a machine integer, it's *the* most
> compact way of specifying the order of anything you'll find.
Except not having to specify it seperately at all, which is what being
able to read the type properties in order would get me.
_______________________________________________
Helma-user mailing list
Helma-user at helma.org
http://helma.org/mailman/listinfo/helma-user
Breton Slivka
Assistant Multimedia Systems Developer
National Gallery of Victoria
180 St Kilda Road Melbourne Vic 3004 Australia
Telephone: +61 3 8620 2348
Fax: +61 3 8620 2555
ngv.vic.gov.au
Keep informed of the latest NGV exhibitions, special events and programs at The Ian Potter Centre: NGV Australia and NGV International by subscribing to NGV at RT, the NGV's free e-newsletter.
DISCLAIMER: This email and any files transmitted with it are confidential and intended solely for helma-user at helma.org. If you are not the named addressee you should not disseminate, copy or alter this email. WARNING: Although National Gallery of Victoria has taken reasonable precautions to ensure no viruses are present in this email, the organisation cannot accept responsibility for any loss or damage arising from the use of this email or attachment.
More information about the Helma-user
mailing list