Home arrow Zope arrow Page 2 - Creating Zope Products

The Stuffing - Zope

The arrangement of Zope objects required for a large website can get somewhat messy and end up looking disorganized. Fortunately, you can use the plethora of Zope Products available to give you a hand, or you can create your own, if there are none that perfectly suit your needs. This article shows you how easy it is to create a Zope Product.

  1. Creating Zope Products
  2. The Stuffing
  3. Inner Mechanisms
  4. Finishing Touches
By: Peyton McCullough
Rating: starstarstarstarstar / 15
March 07, 2006

print this article



The first thing we'll need to do is create an __init__ method. The purpose of this is to accept attributes when an instance of our Product is created. In this example, we'll accept the attributes id, title and nickname:


   def __init__(self, id, title, nickname):
      self.id = id
      self.title = title
      self.nickname = nickname

We can now add actual content to our Product. The methods that we create will be available as separate pages in our Product. These pages can be accessed by attaching the associated method's name to the id of the Product instance in a request (for example, http://localhost/instance/methodOne). We'll start with index_html, the default page that's called when nothing is specifically requested:


   def index_html(self):
      "Default page."
      out = '<html><head><title>' + self.title +
      out = out + 'Hello, I am ' + self.title + ', but my friends
call me ' + self.nickname + '.'
      out = out + '</body></html>'
      return out

In the above method, we return a page that displays the instance's title and the value of the nickname attribute we accepted in the __init__ method earlier. Let's add one more method that lists data about an instance:


   def list_info(self):
      "A list of information."
      out = '<html><head><title>' + self.title +
      out = out + '<b>ID:</b> ' + self.id
      out = out + '<br /><b>Name:</b> ' + self.title
      out = out + '<br /><b>Nickname:</b> ' + self.nickname
      out = out + '</body></html>'
      return out

>>> More Zope Articles          >>> More By Peyton McCullough

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Creating Zope Products
- Plone Content Types With Archetypes
- Flat User Management in Zope
- Creating Basic Zope Applications
- Getting started with Zope for Linux and Sola...
- ZPT Basics (part 4)
- ZPT Basics (part 3)
- ZPT Basics (part 2)
- ZPT Basics (part 1)
- Exception Handling In DTML
- DTML Basics (part 4)
- DTML Basics (part 3)
- DTML Basics (part 2)
- DTML Basics (part 1)
- Using Zope With Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: