[Zope] How does one access a ZClass property from a ZClass method?

Kapil Thangavelu k_vertigo@yahoo.com
Mon, 24 Apr 2000 20:18:00 -0400


"John D. Rowell" wrote:
> 
> On Mon, Apr 24, 2000 at 05:51:20PM -0600, Michael Grinder wrote:
> > I have a ZClass with a property sheet that contains two properties. I then
> > created a method for the ZClass that tried to access the properties. For
> > example: I created a property sheet that contained a float property named
> > "high". I then created a DTML memo in the methods section of the
> > ZClass. But when I put something like <dtml-var high> in the method, I get
> > a KeyError saying that high doesn't exist? Obviously, I'm not
> > understanding something somewhere. What am I doing wrong?
> 
> How are you calling your ZClass? If it is from a <dtml-var> statement,
> you need to specify the namespace explicitly for some odd reason:
> 
>         <dtml-var "zclass.method(zclass, _)">
> 
> Which reminds me, will ZClasses be auto-renderable inside tags in the
> future? It seems silly that you can have an index_html method that is
> rendered from a URL, but have to specify stuff as above to use it from
> other DTML Methods/Documents. Is there a better way that I'm not aware
> of?
> 
> Cheers,
> jdrowell


Ok two questions, 

mike, from your desciption it seems like your trying to view the method
in the management interface of the Control Panel. I'm not up and the
exact details but here goes. When you create a ZClass in the Products
folder, you're basically creating a class definition. but to actually
watch your class in action (ie view, call methods, etc) you need to
instantiate/create an object based on that definition/type in another
folder besides the control panel by selecting your ZClass from the add
item menu. if you're still having problems can you send a traceback and
the show how you call the method.

jd, about renderable Zclasses, try inheriting from the Renderable
Product which basically implements python hooks for __call__, with that
and a render method (i normally define it as index_html) you can render
your ZClasses directly in dtml:

	<dtml-var YourZClass>
	
	or

	<dtml-in "ObjectItems(['YourZClass'])">
	<dtml-var sequence-item>
	</dtml-in>

Kapil
www.sin.wm.edu