Alan Gauld said unto the world upon 2005-02-12 07:51:

<SNIP>

Thanks Alan and Kent for the replies.

I'm responding to a couple of questions Alan asked me about my problem. I don't think I have any further questions of my own (yet), though. :-)

Call it node_linkify. The new thought is to create two new
methods for the TP_file class:

- One to build a dictionary with Node titles as keys and
  a list of the corresponding unique ids as values.


Which saves searching the node list each time, good idea.
This dictionary would of course be part of the Head or Body
object which manages the Nodes?

That's the plan, yes.

- Another to pass that list into a the node_linkify Node method,
once for each Node object of the TP_file.

Since the node knows its own ID and shouldn't know about the other nodes I wonder if it would be better for the Body/Head object to pass only what the node needs to create the links. Or do the links go to *all* the other related nodes? In which case the dictionary entry is fine.

Alan G.

The Node object being linkified won't know which other Node objects need to be linked to until the to-be-linkified Node's article text is scanned. So, I think the full dict is needed. The best analogy I can come up with for what I am trying to do is this:


Consider a wiki which only supports WikiNames rather than arbitrary page names and arbitrary page links. Quite often, in a wiki, people add text which could/should have been in the form of a wiki link, but they didn't format it that way. For example, there might be a page called ExtantWikiName and, on some other page, someone wrote `extant wiki name' rather than `ExtantWikiName'. So, one might want a function which scanned each page of the wiki, looking for strings which match the name of wiki pages, but don't have wiki link formatting and then so format them. It seems to me that this method, if a method of each wiki page, would need to be given knowledge of all page names in the wiki.

That's pretty much my task, save that my target app doesn't support wiki linking, so I need to associate node titles (the analogue of wiki page names) with the unique id's of pages with the title to be able to generate the links.

Off to code it up!

Thanks and best to all,

Brian vdB

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to