Mitch Chapman wrote:
Amos Latteier wrote:
def tpId(self): """Return a value to be used as an id in tree state."""
I've had some problems relating to the tpId() method. Can somebody help sort this out?
After staring at the HTML source for a DTML tree, I eventually realized that tpId()'s return value is used as an HTML "internal" anchor (waddayacallit, it's referenced by <A HREF="doc#anchor">...</A>). So it needs to return a string which makes a valid HTML anchor.
Hm. Good point. The use as an anchor is really secondary. The main purpose of the id is to uniquely identify an object within a tree (or maybe within a branch). The object ids are stored in the tree data cookies to keep track of which branches are expanded. For this reason, the ids should be small. Note that you don't have to define tpId. If it is undefined, then the persistent id (_p_oid) is used if the object is persistent and the Python id will be used if it isn't. Also note that the id is really only needed for expandable objects (objects whose tpValues returns a non-empty list. Finally note that use can use the tag attribute, id, to specify a different method to get an id. (You can also use the url attribute to specify a method other than tpURL.) Sigh. I need to update the tree tag section in the DTML manual.
The HTML generated for a tree node looks something like this:
<TR> <TD WIDTH="16" VALIGN="TOP"><A NAME="someTpIdValue"><A HREF="index_html?tree-e=eJyLVvfMKy5JzMlJLMnMz1MISi3ILyopVtdRUPd3VPArzU1KLVIwUNBwTy3KTcxTcEnMy0zNKdZUjwUAJQAStg#someTpIdValue"><IMG SRC="/cgi-bin/myapp/p_/pl" BORDER=0></A></TD> <TD VALIGN="TOP" ALLIGN="LEFT"> some text </TD> </TR>
Problems: There's no close tag for the anchor (or for the hyperlink, depending on your point of view).
OK, this'll be fixed in the 1.10 release.
'ALLIGN' should be 'ALIGN'.
Hm. The source looks OK here. Someone must've already fixed this. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.