Publishing objects from Zope's products

Creating Zope homemade products is the best way to developing Python web applications without depending (if you don’t want) from Plone. Until last wednesday, I had tried some methods to manage Python’s objects directly from ZPT pages but didn’t work. Other problem with Zope is the documentation and the community, there are too few documentation, and the community of users/developers is too small (for Plone is bigger). Past wednesday my colleague Xavier finds a way to publishing Python’s object directly in a ZPT, when he was following an error log to solve an occurred error. The way is a KISS (Keep It Simple and Stupid) way. Every object in the application that you wants to publish, is mandatory that the object inherits from OFS.SimpleItem, and the object can be used from a ZPT, calling its methods and properties. This is very important for us because we are developing some Zope web applications, and we need a way to design, develops and testing the applications. Now with this discovering we can organize an application like an Object Oriented application without any method/module to pass data through the main core and the ZPT. And this can help us to use PyUnit or homemade scripts to testing the application and do it independent to the presentation layer.

e.g.: Python Class inherited from OSF.SimpleItem

1
2
3
4
5
6
7
8
##OurObject.py
# -*- coding: latin-1 -*-
import OFS.SimpleItem
 
class OurObject(OFS.SimpleItem.SimpleItem):
    def __init__(self, id = '', description = ''):
        self.id = id
        self.description = description

e.g.: Calling object inside a ZPT

29
30
<h1 tal:content="myInstance/id"></h1>
<input type="text" tal:attributes="value myInstance/description" />

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>