Previous Chapter | Up | Next Section | Contents

Using Z Class Instances


To find out more about our class, let's explore an instance.

Click on the "myCD" CD object you just created. You'll note that you can edit the CD's properties with the "Properties" tab, and can edit its security settings with the "Security" tab. Through the management interface you have access to the two management tabs that you defined as "Views" of the Z Class.

As an experiment go back to your Z Class and add another property to the "cd_info" Property Sheet. For example, you could add a "genre" property to your property sheet. Now go back to your CD object, "myCD". You should notice that the new property is now available via the "Properties" management tab. This is the magic of classes. When you change a class, all the instances of the class are effected.

In addition to being able to manage your class instances through the web, you can also access them through DTML. For example, suppose you created a CD object called "SuperOldies_vol42". In a DTML Document you can query this object like so:

<p>Information about a CD:</p>

<dtml-with SuperOldies_vol42>

<p>Title: <dtml-var title></p>

<p>Artist: <dtml-var artist></p>

<p>Description: <dtml-var description html_quote newline_to_br></p>

</dtml-with>

In other words, your CD object is a normal Zope object and you can access its properties just like you access a Folder's properties. You can also manipulate its properties in the same way you manipulate the properties of other Zope objects. For example, here's a DTML fragment that changes some properties of our CD object:

<dtml-call "SuperOldies_vol42.manage_changeProperties({

'title' : 'Super Oldies volume 42',

'artist' : 'Various Artists',

'description' : 'Greatest hits of many has beens.'

})">

Instances of Z Classes inherit all the methods of their base classes. In our simple example, our CD class inherits the basic methods available to all simple Zope Products automatically without having to specify this. In technical terms, all Z Classes inherit from SimpleItem .Item.

Previous Chapter | Up | Next Section | Contents

Banner.Novgorod.Ru