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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
SunQuest
 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? 
ZOPE

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

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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    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


       · Quite a nice guide!
       · This is awesome. =)Before I saw this article I couldn't really grasp the...
       · Thanks for the comments.I wrote the article because a friend of mine was...
       · Nice article - it's always refreshing to see someone covering something other than...
       · Great article. Code 90% works on my instance, but it won't compile with this:...
       · From PicMaster: May be templates are parsed and validated internally by a XML DOM...
       · Is there any way to not have it ask for a username and password when people add a...
     

       

    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-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway