aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-31 18:31:08 +1000
committerDavid Walter Seikel2014-03-31 18:31:08 +1000
commit847c9f9e508734488550d09b592d450892694820 (patch)
tree2c04db44f0f8fba909282e9550959e21fd6bffa9 /ClientHamr
parentTODO++ (diff)
downloadSledjHamr-847c9f9e508734488550d09b592d450892694820.zip
SledjHamr-847c9f9e508734488550d09b592d450892694820.tar.gz
SledjHamr-847c9f9e508734488550d09b592d450892694820.tar.bz2
SledjHamr-847c9f9e508734488550d09b592d450892694820.tar.xz
Notes about Stufflets and SquealStuff.
Diffstat (limited to '')
-rw-r--r--ClientHamr/GuiLua/skang.lua82
1 files changed, 77 insertions, 5 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index fc93c0e..46869a1 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -358,17 +358,89 @@ Other Thing things are -
358 If module.foo is a table, it can have it's own metatable(foo). 358 If module.foo is a table, it can have it's own metatable(foo).
359 Such a table will use Thing as a proxy table via __index and __newindex, as it does now. 359 Such a table will use Thing as a proxy table via __index and __newindex, as it does now.
360 360
361 stuff:stuff('s') -> getmetatable(stuff).__stuff['s']
362
361 test.foo -> test.__index(test, 'foo') -> test.__values[foo]; if that's nil, and test.__stuff[foo], then return an empty table instead? 363 test.foo -> test.__index(test, 'foo') -> test.__values[foo]; if that's nil, and test.__stuff[foo], then return an empty table instead?
362 test.foo(a) -> test.__index(test, 'foo') -> test.__values[foo](a) 364
363 test.foo(a) -> test.__index(test, 'foo') -> test.__values[foo](a) (but it's not a function) -> test.__values[foo].__call(test.__values[foo], a) 365 test.foo(a) -> test.__index(test, 'foo') -> test.__values[foo](a) (but it's not a function) -> test.__values[foo].__call(test.__values[foo], a)
364 Doesn't seem useful. 366 Doesn't seem useful.
365 If test.foo is a Thing then that might be -> test.foo.__call(test.foo, a) -> could do something useful with this. 367 If test.foo is a Thing then that might be -> test.foo.__call(test.foo, a) -> could do something useful with this.
368 So far I have entirely failed to find a good use, since they all are catered for anyway. lol
369
370 stuff.s = {a='foo'} -> changes a, deletes everything else, or should.
371
372 stuff.s[key]={...} -> stuff is a Thing, stuff.s is a Thing, stuff.s[key] NOT a Thing, unless set up before hand, which it is not since [key] is arbitrary.
373 When we do, we would be re using the same Thing for each [key].
374 Except currently Things have a module.
375 rawset(stuff.s, key, skang.copy(stuff.s[''], key)) -- when creating stuff.s[key]
376 So we could do - stuff.s.__stufflets = newThingForStufflets; stuff.s is a Thing, so it goes through __newindex, and these things will get caught.
377 skang.thing{'', module=stuff.s, types='Stuff'} -- Actually, the name is unimportant, this is for stuff with arbitrary names that don't match other Stuff.
378 stuff.s.__stufflets = newThingForStuff
379 stuff.s[''] = {}
380 skang.thing{'field0', module=stuff.s[''], ...}
381 skang.thing{'field1', module=stuff.s[''], ...}
382 So the diff is the existance of stuff.s.__stufflets, if it exists, then stuff.s[key] is checked against it, otherwise it is a non stufflet.
383
384 What we really want is -
385 squeal.database('db', 'host', 'someDb', 'user', 'password') -> Should return a module.
386 local db = require 'someDbThing' -> Same as above, only the database details are encodode in the someDbThing source, OR come from someDbThing.properties.
387 db:getTable('stuff', 'someTable') -> Grabs the metadata, but not the rows.
388 db:read('stuff', 'select * from someTable'} -> Fills stuff up with several rows, including setting up the metadata for the columns.
389 stuff[1].field1 -> Is a Thing, with a __stuff in the stuff metatable, that was created automatically from the database meta data.
390 stuff:read('someIndex') -> Grabs a single row that has the key 'someIndex', or perhaps multiple rows since this might have SQL under it.
391 stuff = db:read('stuff', 'select * from someTable where key='someIndex')
392
393 stuff:stuff('') -> getmetatable(stuff).__stuff['']
394 stuff:stuff() -> getmetatable(stuff).__stuff['']
395
396 stuff:stufflet('field1') -> stuff:stuff().__stuff['field1']
397
398 stuff:write() -> Write all rows to the database table.
399 stuff:write(1) -> Write one row to the database table.
400 stuff:stufflet('field1').isValid = someFunction
401 stuff:isValid(db) -> Validate the entire stuff against it's metadata at least.
402 window.stuff = stuff -> Window gets stuff as it's default stuff, any widgets with same names as the table fields get linked.
403 grid.stuff = stuff -> Replace contents of this grid widget with data from all the rows in stuff.
404 choice.stuff = stuff -> As in grid, but only using the keys.
405 widget.stuff = stuff:stufflet('field1') -> This widget gets a particular stufflet.
406
407 In all these cases above, stuff is a table that has a Thing metatable, so it has __stuff.
408 It also has a .__stufflets.
409 Should include some way of specifyings details like key name, where string, etc.
410 And a way to link this database table to others, via the key of the other, as a field in this Stuff.
411 In Java we had this -
412
413public class PersonStuff extends SquealStuff
414{
415
416...
417
418 public final static String FULLNAME = "fullname";
419
420 public static final String keyField = "ID"; // Name of key field/s.
421 public static final String where = keyField + "='%k'";
422 public static final String listName = "last";
423 public static final String tables = "PEOPLE";
424 public static final String select = null;
425 public static final String stufflets[] =
426 {
427 keyField,
428 "PASSWD_ID|net.matrix_rad.squeal.PasswdStuff|,OTHER",
429 "QUALIFICATION_IDS|net.matrix_rad.people.QualificationStuff|,OTHER",
430 "INTERESTING_IDS|net.matrix_rad.people.InterestingStuff|,OTHER",
431 "title",
432 "first",
433 "middle",
434 "last",
435 "suffix",
436
437...
438
439 FULLNAME + "||,VARCHAR,512"
440 };
441}
366 442
367 stuff.s = {a='foo'} -> changes a, deletes everything else
368 stuff.s{a='foo'} -> only changes a -> stuff.s.__call(stuff.s, {a='foo'} Should allow setting non stufflets, so the below works.
369 443
370 stuff.s[key] = {...} -> stuff.s.key = {...} -> stuff.s = {key={...}} But this semantic means only one thing, which is 'key'.
371 stuff.s{key={...}} -> same as above This does the right thing if we are using 'key' to index rows.
372]] 444]]
373 445
374-- Default things values. 446-- Default things values.