Forum OpenACS Q&A: Response to tcllib nntp

Collapse
2: Response to tcllib nntp (response to 1)
Posted by Dan Wickstrom on
The news package appears to be using a pseudo object-oriented style, so while it appears that you're creating a news handle, what you're really doing is creating a fixed command called news_handle which is used to call the news package commands. If this were a true oo implementation, it wouldn't be a problem to create multiple instances, but since all you're really doing is creating a news_handle proc, the second attempt causes an error. This case could be made to work by adding a test to see if the news handle already exists:

	if ![string length [info commmands news_handle]] {
		set NH [::nntp::nntp "" "" news_handle]
	}
	news_handle authinfo "username" "password"

For the second case, the act of storing the news handle in an nsv_set causes the news handle to be released when the underlying Tcl_Obj type is converted to a string for storage in the nsv_set. nsv_sets only store strings, so there isn't really anything that you can do to make this work.