Zope
  Home arrow Zope arrow Page 2 - Creating Basic Zope Applications
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ZOPE

Creating Basic Zope Applications
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 19
    2005-01-25


    Table of Contents:
  • Creating Basic Zope Applications
  • Categories
  • Topics
  • Replies

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Creating Basic Zope Applications - Categories
    ( Page 2 of 4 )

     

    All right, let's get to work. Create a folder called "forum" with the title "My Forum." This will be our forum's main folder. All of our forum's files should be created in our main folder. Create the folders 1, 2 and 3 with the titles Category One, Category Two and Category Three, respectively. These are our forum's categories.

     

    Next, we need to create an index page with a list of categories. Before we do that, however, let's create a macro to define a basic layout. If you're not too familiar with Zope Page Templates, a macro provides a common look and feel. Say you wanted every page in your site to have a header and footer, yet you need to update the style of the header and footer frequently. You could simplify this process by using a macro. Create a Zope Page Template named base and insert the following text:

     

    <html metal:define-macro='base'>

       <head>

          <title tal:content='container/title'>Page Title</title>

       </head>

       <body>

          <h1 metal:define-slot='title'>Title</h1>

          <span metal:define-slot='content'>Content</span>

          <br />

          Copyright &copy; 2004 Your Website Name Here

       </body>

    </html>

     

    Our macro will allow us to replace "Title" and "Content" with the appropriate text.

     

    Now we'll create the list of categories. Since the separation of presentation and logic is encouraged in Zope, we will use both Zope Page Templates and Python to accomplish this. Create a Zope Page Template object named index_html and insert the following text:

     

    <span metal:use-macro='container/base/macros/base'>

       <h1 metal:fill-slot='title' tal:content='container/title'>Title</h1>

       <span metal:fill-slot='content'>

          <span tal:replace='structure container/getCategories'></span>

       </span>

    </span>

     

    Our macro, base, governs index_html's look.

     

    As you can see, index_html calls the file getCategories. This will be a Python script that retrieves the list of categories and formats it. Create a Script ( Python ) Object named getCategories with the following text:

     

    for category in container.objectValues():

       if category.meta_type == 'Folder':

          print '<a href=\'%s/cat\'>%s</a><br />' % ( category.getId(), category.getProperty ( 'title' ) )

    return printed

     

    If you are not familiar with Python, this script retrieves the objects in its folder. If the object is a folder, it treats it as a category and outputs a link to the file cat with the category's folder as cat's context.

     



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

       

    ZOPE ARTICLES

    - 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek