Zope3Book.it
Il libro degli sviluppatori di Zope 3
The book is also available in the following formats: PDF
Status: IsEditedDraft
The Zope 3 Developers Book aims to provide a solid, but gentle, introduction into the advanced concepts and implementations of the Zope 3 Framework. This book requires some knowledge about Python itself and is therefore aimed at Python and Zope developers, which are interested in the Zope 3 internals, instead of developing Web-based applications. It is the hope of the Zope 3 development community that this complete rewrite of Zope will attract a wider range of Python developers, since many components can be reused completely independent of Zope.
This book is not intended to cover every single aspect of the Zope 3 core software, but serve as a starting point by providing chapters that go into great detail instead of covering a wide range of information. The reader should be able to go to a chapter, read it and after understanding the material know how to complete the original task.
The completed book will be published by Sams Publishing under a free content license in the second or third quarter of 2004. It will be part of the Developer's Library. Much thanks goes to Shelley Johnston (Acquisitions Editor for Sams) for giving us this opportunity. The main author of the book is Stephan Richter and the technical editing will be done by Jim Fulton and Steve Alexander.
I appreciate any contribution to the book, whatever form it may take from correcting spelling/grammar, making technical comments and even writing a chapter/recipe. All contributions will be properly credited in any publication form of the book. If you have any questions, do not hesitate to contact me on the Zope 3 Dev list or at srichter@cosmos.phy.tufts.edu
Thanks, StephanRichter
Una breve introduzione a Zope.
Capitoli
A. Zope 3 visto dall'utente
Questa parte si concentra sull'installazione di Zope 3 sul proprio computer.
- Installare Zope 3 (PDF) - Prima di poter cominciare a provare il codice presentato nei capitoli seguenti, è necessario installare Zope 3 sul proprio sistema. Questo capitolo di introduzione affronteràsolo l'installazione di base, mentre la configurazione avanzata verràtrattata nei prossimi capitoli.
- La nuova interfaccia utente Web (PDF)
- Anche se questo non ha molto a che fare con la programmazione in Python, è
necessario saper utilizzare l'interfaccia grafica, in modo da poter testare le
nuove caratteristiche. VerrÃÂ poi presentata anche l'interfaccia di sviluppo
TTW.
Note: The original futuristic version of this chapter is still available as Zope3GUI. Since Zope X3 3.0.0 does not ship with any scripter or TTW development support, these sections have been removed from the current text.
- Installing New Zope Packages (PDF) - Breve capitolo sull'installazione di pacchetti in Zope 3.
- Setting Up Virtual Hosting (PDF) - Questo capitolo descrive come configurare il virtual hosting in Zope, così come è richiesto per poter utilizzare Apache insieme a Zope 3.
- Synchronizing Through-The-Web Code with the
Filesystem - Zope 3 will come with an
advanced ZODB to Filesystem synchronization tool, similar to
CVS. This will allow people to make local copies of their sites
work on it and check in the changes and much more. This recipe will
explain how to effectively use this tool.
Note: This chapter will not be included in the first version of the book, since Zope X3 3.0.0 will not ship with it and it is not actively maintained at this point.
B. The Ten-Thousand Foot View
Here an overview over some of the fundamental ideas in Zope 3 is given without jumping into the technical detail. The reader might prefer to read these chapters after reading some of the more hands on sections, like the ones that follow.
- The Zope 3 Development Process (PDF) - This chapter briefly introduces the process that is used to develop and fix components for Zope 3.
- Introduzione alle interfacce (PDF) - Since Interfaces play a special role in Zope 3, it is important to understand what they are used for and what they offer to the developer.
- Introduzione all'architettura a componenti (PDF) - An overview over components and their possible interaction.
- Schemi e widget nelle form in Zope 3 (PDF) - One of the powerful features coming up over and over again in Zope 3, are schemas, an extention to interfaces that allows attributes to be specified in more detail allowing autogeneration of forms as well as the conversion and validation of the inputted data.
- Introduction to the Zope Configuration Markup Language (ZCML) (PDF) - While you are probably familiar with ZCML by now, it is always good to review.
- Introduction to Zope's I18n and L10n Support (PDF) - This introduction presents the new I18n and L10n features of Zope 3 and demonstrates how a developer can completely internationalize his/her Zope application. I18n in ZPT, DTML, ZCML and Python code will be discussed.
- Meta Data and the Dublin Core (PDF) - Everyone knows about it, everyone talks about it, but few know the details. Naturally, the fields of the Dublin Core will be discussed and how they can and should be used.
- Porting Applications (PDF) - For many developers it is very important to have a migration path from their Zope 2 applications to Zope 3. This chapter will concentrate on the technical aspects and discuss the design changes that have to be applied to make an old Zope application fit the new model. The port of ZWiki will be used as an example.
C. Content Components - The Basics
This section deals with the creation of content objects and basic functionality around them. In order to make the recipes flow better, they will be all guided by the creation of a simple message board.
- Writing a new Content Object (PDF) - This recipe will describe how to implement a new simple Content Object.
- Adding Views (PDF) - This recipe will demonstrate various methods to create Browser-specific views for a component.
- Custom Schema Fields and Form Widgets (PDF) - This recipe basically tells you how to implement your own field and corresponding widget. It will then be demonstrated how this Field and Widget can be used in a Content object.
- Securing Components (PDF) - Zope 3 comes with an incredible security system; but the best system is only as good as the end developer using it. This recipe will give some hands-on tips and tricks on how to make your code secure.
- Changing Size Information (PDF) - There exists a small interface for content objects that will allow them to display and compare their size. This is a short recipe explaining this feature.
- Internationalizing a Package (PDF) - This recipe will give step by step instructions on how to internationalize the content object we developed in the previous recipes and how to create a German translation for it.
D. Content Components - Advanced Techniques
Having a well-working basic message board is great, but it is certainly not blowing away anyone. In this section some more advanced APIs? are presented.
- Events and Subscribers (PDF) - Events et al are a very powerful idea. This chapter will explain how to write your own event subscribers by implementing a mail subscription feature for messages.
- Approval Workflow for Messages (PDF) - This chapter will show how to integrate an editorial workflow for a content component.
- Providing Online Help Screens (PDF) - Every good application should have Online Help screens, which is outlined in this chapter.
- Object to File System mapping using FTP as example (PDF) - While there are standard hooks for content objects to be handled by FTP, it is often useful to write your own FTP handlers, so that the file-to-object conversion (and the other way around) seems more natural.
- Availability via XML-RPC (PDF) - If you want to make XML-RPC calls on your content objects, you must write a view declaring the methods and define how their output is mapped to a type that XML-RPC understands.
- Developing new Skins (PDF) - This chapter gives instructions on how to implement a new skin, so that sites can be developed that do not look like the Zope Management Interface, but still allows us to make use of all the auto-generation of forms.
E. Other Components
From the introduction chapters you know that content objects are not the only type of component you want to write. This section covers several of these various other components, such as utilities and resources.
- Building and Storing Annotations (PDF) - Since it is desirable to leave an object as untouched as possible, we developed a mechanism for attaching meta data to an object without the object knowing about it.
- New Principal-source plugins (PDF) - Many people have very different requirements on the mechanism an authentication service should function and Zope 3 respects this need. There exists an Authentication Service that accepts plugins to provide principal data from external data sources.
- Principal Annotations (PDF) - A common task is to append data to principals. Since principals are often imported from external data sources, they are not attribute annotatable. This chapter will make use of the Principal Annotation service to store additional data.
- New Resources (PDF) - This is a short chapter telling the reader how to implement a new file system based resource (a context independent view).
- Registries with Global Utilities (PDF) - Utilties can be used to implement Zope-wide registries. Since registries are so very useful, this chapter is a must.
- Local Utilities (PDF) - While we saw already how simple it is to write global utilities, there is some more work to do for local utilities, which will be introduced in this chapter.
- Developing a Lucene-based Text Index - While
there are many indices that will be shipped with Zope 3, it is
sometimes necessary to write an index that makes use of external
indexing software for example, such as Lucene or many other. This
recipe will explain in detail on how to connect Lucene to Zope 3 as
a full-text indexing engine.
Note: This chapter will not be included in the first version of the book, since Zope X3 3.0.0 will not ship with index support and it has already been totally rewritten for 3.1.
- Vocabularies and Related Fields/Widgets (PDF) - Vocabularies are a powerful extension to the schema framework and provide a generic method to create fields with variable and context dependent selection lists.
- Exception Views (PDF) - For Zope 3, exceptions are simply objects, which can have views that make them representable on any output medium (usually the browser). Every exception has a standard view, but for a professional Web site you will need better screens.
F. Advanced Topics
Not everything you ever want to develop are components that you would
allow the user to add and manipulate. This section contains a
collection of chapters that deal mainly with the packages outside of
zope.app. These packages are often useful outside of Zope 3 as well.
- Writing new ZCML Directives (PDF) - Here we iscusses how new directives can be added to a ZCML namespace using meta-directives and/or how to create a new namespace from scratch.
- Implementing a TALES Namespace (PDF)
- In Zope 3, Zope Page Templates (TALES expressions) can contain
namespaces to provide easier access to an object's data and
meta-data. While Zope 3 provides a
zopenamespace, it is sometimes extremely helpful to develop your own to expose your product-specific API. - Changing Traversal Behavior (PDF) - Similar to Zope 2, one can change the traversal (lookup) behavior for an object, except that this functionality is much more flexible in Zope 3.
- Registering new WebDAV Namespaces (PDF) - WebDAV? is allowed to store and request any namespace on any resource. However, we want to have some control over the namespaces and their values. This chapter explains how to bind Zope 3 attributes and annotations to WebDAV? namespaces.
- Using TALES outside of Page Templates (PDF) - TALES is a powerful expression mechanism that certainly does not only find usage in Page Templates. This chapter tells you how to incorporate TALES into your own Python applications and scripts.
- Developing a new TALES expression (PDF)
- While TALES is powerful in itself, one can make it even more powerful
by implementing custom expressions. The chapter will explain step
by step how the
sqlexpression was created. - Spacesuits -- Objects in Hostile Environements (PDF) - While the term "spacesuits" is not used in the Zope 3 terminology anymore, it best describes the approach of the new security model, which will be introduced in this chapter.
- The life of a Request (PDF) - This chapter will show the request's exciting journey through the server, publisher and publication frameworks.
G. Writing Tests
Writing tests for every bit of functionality is of upmost importance in Zope 3. Testing can be done in many ways, from Java-like unit tests to pythonic Doc Testing.
- Writing Basic Unit Tests (PDF) - This chapter shows you how to develop basic unit tests for your code and explains in detail how various pieces of functionality can be tested.
- Doctests: Example-driven Unit Tests (PDF) - Sometimes regular unit tests are not as instructive to someone reviewing the code. In these cases it is shown how example-driven doctests can be useful.
- Writing Functional Tests (PDF) - Unit tests are great for testing isolated components, but are impractical for testing entire sections of the system. For these type of tests we use a functional testing framework, which is introduced here in some detail.
- Writing Function Doc Tests (PDF) - For the same reason doctests were developed to supercede unit tests, functional doctests are intended to be a more descriptive solution to develop functional tests.
- Writing Tests Against Interfaces (PDF) - If an interface is commonly implemented multiple times, it is a good idea to write tests directly against the interface as a base for the implementation tests. This chapter will show you how to do that and expand on the motivation.
Appendix A: Glossary (PDF)
A glossary of terms for the book. This differs from the official Wiki glossary and is meant to give a different perspective. I intentionally did not look at the existing glossary or its list of terms, so that this one would provide a unique point of view.
Appendix B: Credits (PDF)
This mini section contains a list of all contributors to the cookbook. I want to give everyone the proper credit.
Appendix C: Creative Commons License
This book is licensed under the Creative Commons Attribution-NoDerivs?-NonCommercialLicense? 1.0.
Appendix D: Zope Public License 2.1
The example code is maintained in the Zope CVS under the ZopePublicLicense.
Use the RecipeTemplate to start writing your own recipe. See DifficultyLevel for list of the various difficulties of the chapters.
