NODE_CACHE format should be the standard format for our topic tree. It's a much more simple representation, more amenable to editing and fast searching.
The major issue with NODE_CACHE is that it can't be saved easily--parent, parents, and children all have object references that wind up creating loops.
So, here's how to save/load NODE_CACHE to/from disk. Then, TOPICS just becomes NODE_CACHE['Topic'][""]:
convert parent, parents, and children to slugs before streaming to disk
after loading from disk, convert those slugs into actual object references in a simple loop. Efficient, as lookup in a dict is hashed, so fast.
That's it! Then, editing becomes so easy, to add / edit / delete nodes. No tree structure needed for navigation; just add, setting all properties necessary on the node, and you're done!
NODE_CACHE
format should be the standard format for our topic tree. It's a much more simple representation, more amenable to editing and fast searching.The major issue with
NODE_CACHE
is that it can't be saved easily--parent
,parents
, andchildren
all have object references that wind up creating loops.So, here's how to save/load NODE_CACHE to/from disk. Then,
TOPICS
just becomesNODE_CACHE['Topic'][""]
:parent
,parents
, andchildren
to slugs before streaming to diskThat's it! Then, editing becomes so easy, to add / edit / delete nodes. No tree structure needed for navigation; just add, setting all properties necessary on the node, and you're done!