[Zope] Tree Tag Options

Mitch Chapman mchapman@OEE.com
Wed, 03 Feb 1999 11:05:20 -0500


Jim Fulton wrote:
> 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.

I shot myself in the foot on this one.  Early on I came across 
Zope's TreeItem.TreeProtocol class, and decided to use it as a 
mixin.  Of course TreeProtocol is a protocol specification, and 
its tpId method doesn't return anything. So I browsed around
to see how it was used.

After concluding that tpId served as an anchor name,  I tried 
returning id(self).  (It's a valid anchor name, and it's unique.)
At which point tree nodes stopped expanding when clicked.

So I looked at TreeTag.py, saw *it* using Python object 
IDs -- and working -- and decided it was time for beer.

There's a moral here, and someone less addle-brained could
state it clearly.  Here's my attempt:  In Python, protocol 
specs aren't gospel.  The client framework may, like TreeTag.py, 
be able to adapt if you don't conform strictly to the protocol.

Or how about:  Think twice before mixing in a protocol class.

-- 
Mitch Chapman			  |	4105 Executive Drive
Ohio Electronic Engravers, Inc.	  |	Beavercreek, OH  45430
mchapman@oee.com		  |	import StandardDisclaimer