An Outdated Developer's Guide to Learning Zope (v1.0.3)
Itamar Shtull-Trauring <zope@itamarst.org>
Important: This guide was written for Zope 2.2 and is extremely out of date
Contents
- Contents
- 1 Introduction
- 2 Preliminaries
- 3 Zope Newbie
- 4 Zope Journeyer
- 5 Zope Master
- 5.1 Zope Core Development
- 5.2 Custom ZODB Storages
- 5.3 Zope Enterprise Objects
- 5.4 Caching
- 5.5 Discussion Groups
- 5.6 ZPatterns
- 5.7 Membership and User Sources
- 5.8 Portal Toolkit
- 5.9 Scheduling
- 5.10 XML
- 5.11 XML-RPC, SOAP and ZPublisher.Client
- 5.12 Session Management
- 5.13 eCommerce
- 5.14 Perl Methods
- 5.15 Virtual Hosting and other URL mangling
- 5.16 I18N and L10N
- 5.17 Other Useful Tools
- A. Getting Help
1 Introduction
Zope is a web application environment developed by Digital Creations - DC for short.
This document is not going to tell you why you should use Zope. Instead, it intends to point out resources that will allow you to learn how to use Zope. For an introduction on how Zope works, visit http://www.zope.org/WhatIsZope. In this document I describe the different levels of knowledge using terms I borrowed from Advogato http://www.advogato.org - Apprentice, Journeyer and Master. As you advance in your knowledge you will advance in your category, until at last you are a Master, and you to answer Newbies' questions.
1.1 Conventions
If I refer to a file, unless I state otherwise this refers to a subdirectory of $ZOPEHOME/lib/python/. For example, If Zope is installed in /home/zope, then the file OFS/Image.py can be found in /home/zope/lib/python/OFS/Image.py.
I assume Zope is installed on your local machine, so that Zope can be accessed at http://localhost:8080.
1.2 General suggestions
- The Source is your friend. The Zope source code has lots of embedded documentation and examples - use it.
- http://www.zope.org has hundreds of Howtos, tips, Products, documentation.
- You can find lots of info at the Zope Documentation Project: http://zdp.zope.org
- Both O'reilly and Wrox will soon be publishing books on Zope, and other publishing houses will be as well in the near future. Till they're available, you can read the text of the O'reilly book at http://www.zope.org/Members/michel/ZB/.
2 Preliminaries
Before you start using Zope, you're going to need to learn a few things which will help you understand how it works.
2.1 Python
Python is the programming language in which Zope was written. Knowledge of Python is a must if you intend to start developing serious Zope applications, and will also help in understanding DTML and other basic parts of Zope. Zope currently uses Python 1.5.2, but in the future will be upgraded to use Python 2.x.
The main resource for Python is http://www.python.org. The documentation section at http://www.python.org/doc/ has most or even all of the info you need to learn Python, starting with the Tutorial http://www.python.org/doc/current/tut/tut.htmland moving onwards from there.
There a number of books written about Python -- there's a complete list at http://www.python.org/psa/bookstore/. I especially liked Python Essential Reference (http://bn.bfast.com/booklink/click?sourceid=10922&ISBN=0735709017) which as the title says, is an essential Python reference.
There's an introductory talk on Python at http://shell.rmi.net/~lutz/talk.html.
The Python development team's homepage is http://www.pythonlabs.com, and the Python CVS, bug reporting system is at http://python.sourceforge.net.
2.2 HTTP, CGI, Cookies
A nice tutorial on how the web works can be found at http://www.stud.ifi.uio.no/~lmariusg/download/artikler/HTTP_tut.html.
The main way to communicate with Zope is via the HTTP protocol, and it gets its arguments via the CGI protocol. Some knowledge of both can be indispensable for debugging certain problems.
You can find the basic info for HTTP at the W3C http://www.w3c.org. See RFCs 2616, 2617 and 1867. You can find nice HTML versions of the RFCs at http://community.roxen.com/developers/idocs/, and the HTTP 1.1 RFC (2616) at http://www.w3.org/Protocols/rfc2616/rfc2616.html.
You can learn about cookies at http://home.netscape.com/newsref/std/cookie_spec.htmland RFCs 2109 and 2965.
The main reference for the way CGI works can be found at http://Web.Golux.Com/coar/cgi/.
3 Zope Newbie
OK, you've installed the latest version of Zope (http://www.zope.org/Products/Zope). Now what?
The single most complete resource for newbies is the upcoming O'Reilly book Zope: The Definitive Guide, by Amos Latteier and Michel Pelletier (the title is inaccurate - the book mainly covers the basics of using Zope). The book has not yet been published, but you can read the existing text at http://www.zope.org/Members/michel/ZB/. While not totally finished, the existing text contains major amounts of useful information, and it's getting better every day. All the resources I mention in the Newbie section probably have equivalent info in the book, so check there first.
Another great resource is Zope's online help - this can be accessed by clicking the Help button in any management screen, or at http://localhost:8080/HelpSys. It includes help for management screens, an API reference for DTML developers, and in newer versions of Zope (2.2.3 and later) a DTML reference as well.
Other useful resources for newbies:
- DTML Reference:http://www.zope.org/Documentation/Guides/DTML-HTML/DTML.html
- ZSQL Methods: http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.html
- ZClasses: http://www.zope.org/Documentation/Guides/ZDG-HTML/ZDG.6.html
3.1 ZCatalog
The ZCatalog is Zope's built in indexing and searching engine, used to catalog Zope objects. You can learn about it at:
- ZCatalog Tutorial: http://www.zope.org/Documentation/How-To/ZCatalogTutorial
- Advanced ZCatalog Howto: http://www.zope.org/Members/Zen/howto/AdvZCatalogSearching
- CatalogAwareness Howto:http://www.zope.org/Members/AlexR/CatalogAware
- Index types: http://www.zope.org/Members/AlexR/KeywordIndexes
4 Zope Journeyer
Now that you've mastered Zope basics, its time to move on, and learn more about how Zope works internally.
4.1 Zope APIs
In order to work with Zope's internals, you need to know its APIs. In addition to the public ones documented in Zope's online help, you can find more info about Zope's internal APIs by:
- Reading the source code. Always a good idea.
- Visiting the Interfaces Wiki. The information is not always accurate or up-to-date, but it's still very useful: http://www.zope.org/Members/michel/Projects/Interfaces/FrontPage
4.2 Creating Zope Products
Extending Zope by adding Products is the standard way of creating advanced Zope applications. There are two main references for this:
- An excellent Product creation tutorial: http://www.zope.org/Members/hathawsh/PythonProductTutorial
- Product Developer's Guide: http://www.zope.org/Members/mcdonc/PDG
4.3 ExtensionClass and Acquisition
ExtensionClass is a Python package that allows developers to create, in C, classes for Python that can be subclassed in Python. It's used for the Acquisition and Persistence support in Zope.
- The latest ExtensionClass and Acquisition code comes with Zope, in the source distribution.
- ExtensionClass documentation: http://www.digicool.com/releases/ExtensionClass/
- Acquisition documentation: http://www.digicool.com/releases/ExtensionClass/Acquisition.html
- What is Acquisition? http://www.zope.org/Members/Amos/WhatIsAcquisition
- Acquisition Algebra: http://www.zope.org/Members/jim/Info/IPC8/AcquisitionAlgebra/siframes.htm
4.4 ZODB, Persistence and Transactions
ZODB is Zope's built-in object database. Objects that are stored in it must inherit from the Persistence class (an ExtensionClass). ZODB is a transactional database.
- AMK's ZODB pages: http://www.kuchling.com/zodb/
- Paper on ZODB by Jim Fulton: http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html
- ZODB Howto: http://www.zope.org/Members/michel/HowTos/ZODB-How-To
- ZODB UML Model: http://www.zope.org/Documentation/Developer/Models/ZODB
- Transactions Howto: http://www.zope.org/Members/mcdonc/HowTos/transaction
4.5 Creating custom DTML tags
DTML allows you to create your own custom tags. Check out the Mailhost product's <dtml-sendmail> tag in Products/MailHost/SendMailTag.py in your Zope install for an example, and also the MIMETools products (Products/MIMETools).
There's a Howto that explains how: http://www.zope.org/Members/z113/1.
4.6 Pluggable Brains
ZCatalog and ZSQL searches can use ZClasses or Python classes as pluggable brains, to give some ``intelligence'' to the returned records. You can learn about them at http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.4.6.4.html.
4.7 Debugging
- The Debugger is your friend: http://www.zope.org/Members/michel/HowTos/TheDebuggerIsYourFriend
- A number of debugging techniques: http://www.zope.org/Members/klm/debuggingzope
- Tracking down hangs using the debug log: http://www.zope.org/Members/mcdonc/HowTos/DEBUG-LOG
- Debugging with the monitor: http://www.zope.org/Documentation/Misc/DEBUGGING.txt
- Debugging notes from the mailing-lists: http://www.zope.org/Members/teyc/howtoDebugZope2
5 Zope Master
Having mastered the knowledge required of a Journeyer and Apprentice, you are now a Zope Master. That doesn't mean there's nothing left for you to learn - quite the opposite in fact. This is just an overview of the different topics you can look into in more depth.
5.1 Zope Core Development
Keeping up with the latest Zope developments is very important.
- You can check out the latest development Zope version from CVS to try out new cutting-edge (and buggy) features: http://www.zope.org/Resources/CVS_info. You can browse the CVS repository online at http://cvs.zope.org. More info can be found at http://www.zope.org/Resources/CVS.
- Proposals for Zope development, and info on the latest Zope core additions can be found at http://dev.zope.org.
- Thanks to HappyDoc, a Python documentation extraction program, you can browse and download the Zope source-code documentation (extracted from docstrings and comments) at http://www.zope.org/Documentation/Developer/ZopeSrcDocs.
5.2 Custom ZODB Storages
The ZODB is usually stored in a FileStorage type storage, in a file called Data.fs. However, you can store it in other types of storage as well:
- Oracle Storage - store the ZODB in Oracle: http://www.zope.org/Products/OracleStorage
- Berkeley DBM storage: http://www.zope.org/Members/tsarna/BerkeleyStorage
- Compressed Storage: http://www.zope.org/Members/tsarna/CompressedStorage
- Directory Storage: http://www.ppetru.net/software/index.html
- Zope on a CD (read-only storage): http://www.zope.org/Members/jens/docs/zope_on_cdrom
- Look around in the ZODB/ directory in your Zope install - there are additional examples there.
5.3 Zope Enterprise Objects
ZEO extends ZODB by turning it into a distributed object database. This lets you serve the same Zope database from different machines, test development code on the same database as your live site, and other uses. Find out more at http://www.zope.org/Products/ZEO.
5.4 Caching
There are two sorts of caching - internal Zope caching and HTTP caching. For info on HTTP caching, check out http://www.mnot.net/cache_docs/. You can see of an example of how Zope implements these headers in OFS/Image.py in the FILE class. Some information on using caching headers in Zope can be found at http://www.zope.org/Members/htrd/howto/caching?pp=1.
The next version of Zope (2.3) will contain a Caching Manager that will allow internal caching: http://dev.zope.org/Wikis/DevSite/Projects/CacheManager/.
5.5 Discussion Groups
There a number of different products implementing discussion abilities for Zope. The two main ones are Squishdot (http://www.squishdot.org) and ZUBB (http://www.zope.org/Members/BwanaZulia/ZUBB).
5.6 ZPatterns
ZPatterns is an advanced development framework for Zope, including an event model, generic data providers, and lots of really complex, cool stuff you'll really love once you figure out how to use them. Which can take a while. http://www.zope.org/Members/pje/ZPatternshas the product and some documentation.
5.7 Membership and User Sources
Zope by default only lets you store users in the ZODB and authenticate using Basic HTTP Authentication. If you want to store your users in a SQL database, get them off LDAP, or authenticate using cookies, you need an alternative to Zope's User Folder.
The most advanced alternative is LoginManager (http://www.zope.org/Members/tsarna/LoginManager), that lets you plug-in different authentication methods and user sources. Getting users off SQL/LDAP/Windows/passwd is very easy, you just need to write the correct methods: http://www.zope.org/Members/jok/SQL_based_LoginManager is an example of how to use SQL. You can find other, less general, methods of getting users at http://www.zope.org/Products/user_management.
The Membership Product (http://www.zope.org/Members/Bill/Products/Membership) gives you support for membership - allowing users to join, choose a password, set their preference, etc..
5.8 Portal Toolkit
PTK has everything you'd expect of a portal, and allows you to develop your own custom ones. The best example is of course http://www.zope.org, which is running an ancient version of the PTK. You can find out more at http://www.zope.org/Products/PTK.
5.9 Scheduling
Scheduling events in Zope can be done in two ways:
- Externally, for example using cron: http://www.zope.org/Members/lalo/cron, http://www.zope.org/Members/phd/cron-zope.
- Internally, using the Xron product: http://www.zope.org/Members/lstaffor/Xron.
5.10 XML
Zope has extensive XML support, including access to the ZODB using the DOM API. The next version of Zope will have support for XSLT and better XML and DOM support. You can find out more at the XML Wiki: http://www.zope.org/Wikis/zope-xml/FrontPage.
5.11 XML-RPC, SOAP and ZPublisher.Client
Zope can be accessed not only using HTTP, FTP and WebDAV, but also by RPC mechanisms such as XML-RPC.
- XML-RPC article by Amos Latteier: http://www.xml.com/pub/2000/01/xmlrpc/
- XML-RPC Howto (also Amos): http://www.zope.org/Members/Amos/XML-RPC
- Article by Jon Udell on XML-RPC in Zope: http://www.byte.com/column/BYT19991021S0014
- Patches to add SOAP support to Zope, from Petru Paler: http://www.ppetru.net/software/index.html
- Zope contains, in ZPublisher/Client.py a client for ZPublisher.
5.12 Session Management
The next or maybe next-next version of Zope will contain built-in session management (http://dev.zope.org/Wikis/DevSite/Projects/CoreSessionTracking/). Until then, you can choose from a number of different session Products:
- SQL sessions: http://www.zope.org/Members/anthony/software/SQLSession
- Memory-based sessions: http://www.zope.org/Members/hungjunglu/Products/HappySession
- Filesystem sessions: http://www.zope.org/Members/gaaros/FSSession
- Cookieless sessions: http://www.zope.org/Members/czimmet/CookieLess
5.13 eCommerce
There are a number of ecommerce products for Zope.
- etailer is a wonderful store front product: http://e-tailer.adroit.net
- zCommerce is a store front from CodeIt: http://www.zope.org/Members/ngarcia/zCommerce
- Wampum is another CodeIt product, allowing you to connect to CyberCash from Zope and Python: http://www.zope.org/Members/ngarcia/WampumGenerator
- EMarket is a simple shopping cart Product: http://www.zope.org/Members/sspickle/EMarket
5.14 Perl Methods
Yes, you can use Perl from Zope! http://www.zope.org/Wikis/zope-perl/FrontPageis the place.
5.15 Virtual Hosting and other URL mangling
SiteRoot is a nifty product that allows you to mess around with the way Zope thinks about its base URL. It allows you to do virtual hosting from Zope, and some more dangerous and useful stuff: http://www.zope.org/Members/4am/SiteAccess2.
5.16 I18N and L10N
There a number of products for internationalization and localization. You can find them at http://www.zope.org/Products/internationalization. The next version of Zope will contain some support for skinnable management screens - see http://dev.zope.org/Wikis/DevSite/Projects/SkinnableAndLocalizableObjects/
5.17 Other Useful Tools
- WorldPilot is a web-based groupware package (http://www.worldpilot.org)
- Python Imaging Library allows you to create images from inside Python, and thus Zope (http://www.pythonware.com/products/pil/)
- Reportlab is a python package for generating PDFs (http://www.reportlab.com)
- MetaPublisher is a helpful tool to create complex forms. It permits you to manage large amounts of data without having to know how to program. If you're a Zope Master you do know how to program - but how about your users? http://www.beehive.de.
- ZWiki is a Wiki product for Zope - page that can interactively and cooperatively edited by users (http://www.zope.org/Members/simon/ZWiki)
- LocalFS lets you serve files from the harddisk using Zope (http://www.zope.org/Members/jfarr/Products/LocalFS/).
A. Getting Help
At some point, you're going to get stuck. That's when you need to ask someone for help. There's always someone nice on the mailing-lists or IRC who'll help you, so feel free to ask.
A.1 Commercial Support
You can get commercial support for Zope from a number of companies, including of course Digital Creations: http://www.zope.org/Resources/ZSP.
A.2 Mailing lists
Zope has a number of busy mailing-lists, on a number of topics including ecommerce, PTK and internationalization. For a full list of lists and instructions on subscribing visit http://www.zope.org/Resources/MailingLists. There are nice searchable archives of some of the lists at http://zope.nipltd.com/public/lists.html.
A.3 IRC
There's a busy #zope channel on irc.openprojects.net. Recent topics included bouncing sheep and LYX. Sometimes we even discuss Zope. Logs can be found at http://charizard.blazingfast.net/~irclord/zope-logs/.
A.4 Reporting bugs
Think you've found a bug in Zope? Submit it at http://classic.zope.org:8080/Collector.