Author: tziade Date: Sat Mar 18 23:13:37 2006 New Revision: 2656 Modified: cookbook/trunk/cookbook.en.kilepr cookbook/trunk/cookbook.fr.kilepr cookbook/trunk/recipe57.en.tex Log: finished part about file based / module based, and removing lasts parts (5 pages recipe already, it's getting to big)
Modified: cookbook/trunk/cookbook.en.kilepr ============================================================================== --- cookbook/trunk/cookbook.en.kilepr (original) +++ cookbook/trunk/cookbook.en.kilepr Sat Mar 18 23:13:37 2006 @@ -71,16 +71,16 @@ [item:recipe57.en.tex] archive=true -column=0 +column=12 encoding=ISO 8859-15 highlight=LaTeX -line=52 +line=82 open=true [item:recipe58.en.tex] archive=true -column=0 +column=5 encoding=ISO 8859-15 highlight=LaTeX -line=20 +line=57 open=true Modified: cookbook/trunk/cookbook.fr.kilepr ============================================================================== --- cookbook/trunk/cookbook.fr.kilepr (original) +++ cookbook/trunk/cookbook.fr.kilepr Sat Mar 18 23:13:37 2006 @@ -1,7 +1,7 @@ [General] img_extIsRegExp=false img_extensions=.eps .pdf .dvi .ps .fig .gif .jpg .jpeg .png -lastDocument=file:///home/svn.z3lab.org/cookbook/recipe00.fr.tex +lastDocument=file:///home/svn.z3lab.org/cookbook/recipe57.fr.tex masterDocument= name=Zope 3 Cookbook, Français pkg_extIsRegExp=false @@ -74,7 +74,7 @@ column=0 encoding=ISO 8859-15 highlight=LaTeX -line=5 +line=19 open=true [item:recipe58.fr.tex] Modified: cookbook/trunk/recipe57.en.tex ============================================================================== --- cookbook/trunk/recipe57.en.tex (original) +++ cookbook/trunk/recipe57.en.tex Sat Mar 18 23:13:37 2006 @@ -28,7 +28,7 @@ In Zope, the package has an extended meaning: it's the smallest pluggable part of the server. This was known as \textit{Product} under Zope 2. Since the initialization mechanism is based on the ZCML files, Zope acts the same way -as Python, but looks for a \code{configure.zcml} in the package folder. +as Python, but also looks for a \code{configure.zcml} in the package folder. From there, any kind of code organization would work, as long as the modules are linked in the ZCML file. But a bit of structuration is needed, based on a @@ -171,23 +171,64 @@ >>> my_counter_view.getCount() 'I have been seen 3 times' \end{verbatim} +Everything is hooked up in the ZCML, with a few browser directives: +\codetitle{The final configure.zcml:} +\begin{verbatim} +<configure + xmlns="http://namespaces.zope.org/zope" + xmlns:browser="http://namespaces.zope.org/browser" + i18n_domain="zope" + > + + <content class=".dummycounter.DummyCounter"> + <require permission="zope.View" + interface=".interfaces.IDummyCounter" /> + </content> + + <browser:page + for=".interfaces.IDummyCounter" + name="counter.html" + permission="zope.View" + class=".browser.DummyCounterView" + attribute="getCount" + /> + + <browser:addform + schema=".interfaces.IDummyCounter" + label="Add dummy counter" + content_factory=".dummycounter.DummyCounter" + name="AddDummy.html" + permission="zope.ManageContent" + /> + + <browser:addMenuItem + class=".dummycounter.DummyCounter" + title="Dummy Counter" + permission="zope.ManageContent" + view="AddDummy.html" + /> -\subsection*{Choosing between module-based or folder-based} - -***talk about the choice browser.py <-> browser folder etc... - -\section*{Adding tests} +</configure> +\end{verbatim} -***talk about tests folder, tests.py, ftests.py, text files for -doctests etc.. +\subsection*{Choosing between module-based or folder-based} -\section*{Adding specific elements} +So far, our package is composed of five files: -***talk about meta.zcml, resources, etc.. +\begin{itemize} +\item \_\_init\_\_.py: tells Python it's a package +\item configure.zcml: tells Zope it's a package, and sets everything +\item interfaces.py: groups all interfaces +\item dummycounter.py: implements the content object +\item browser.py: implements the browser view +\end{itemize} -\section*{Splitting up a growing package} -***talk about pure python package , stuff like that +This structure is a module-based structure, and fits well for our simple +example. When the package gets bigger, it's better to use a folder-based +organization, by making \code{interfaces} and \code{browser} become +subfolders. The \code{browser} folder can then hold its own +\code{configure.zcml}, included in the main ZCML file, and so forth. \end{solution} \end{document} -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins