[Zope] ZClass, acquisition, dtml confusion

Jon Franz jfranz@one.net
Fri, 8 Sep 2000 13:23:49 -0400


Hello,
	Previously I made a DTML method that when used within a 
DTML Document would modify properties on that document.  
Having this floating around in root made it visible to the 
whole site, but seemed 'unclean'.  So, I attempted to make 
the DTML method into a ZClass, and making the index_html 
method in the ZClass contain the exact same DTML as the 
method... But it doesn't work.  So, I tried again - this 
time with as simple a method as possible, a very basic 
counter.  The DTML method I made in root increments and 
displays the 'z_count' property on the page that calls it, 
and creates the property if it doesn't exist, so using it 
is as simple as:

<dtml-var mycount>

However, I place the DTML into a new class, and then make 
a new instance of the class, and it wont work as above.  
I now have to do this:

<dtml-with MyZCCount>
<dtml-var MyZCCount>
</dtml-with>

And, instead of modifying the property of the calling document, 
it modifies the parent folder's properties.  Below is the DTML, 
can someone please explain what I need to do to get this to 
work on the calling DTML document instead?  If I can't get 
this simple counter to work I'm going to go mad, since changing 
properties is something I need to be able to do from many of my 
planned ZClasses... Thanks in advance!

<dtml-if "hasProperty('z_count')">
  <dtml-var "'%06d' % (z_count + 1)">
  <dtml-call "REQUEST.set('z_count', z_count + 1)">
  <dtml-call "manage_changeProperties(REQUEST)">
<dtml-else>
  <dtml-call "manage_addProperty('z_count', 1, 'int' )">
  000001
<dtml-if>