[Zope] Organizing Zope Content
Maik Roeder
roeder@berg.net
Thu, 13 Jan 2000 22:04:11 +0100
Hi !
I would propose using ZClasses from the start for your
project.
> > I'm looking for ideas on how to structure my content. For
> > example, one of
> > my pages needs to display headlines with little snippets of
> > the article
> > itself. Clicking the headline would cause the full article to
> > display.
You have the domain object article. A newsitem is just a view
on the articles. Articles should be contained in a controller
you can call something like ArticleFolder.
> > What I want to be able to do is build a structure
> > such that I
> > could iterate over items, pick up headlines, and generate the
> > headlines
> > page dynamically.
You can create a Folder on your site like "News". Inside, you
use a view created by a ZCatalog to show articles with headlines.
> When you have a collection of objects you want to iterate over, it is
> useful to put them in a container-like data structure, like a Folder.
I would put the Articles inside an ArticleFolder ZClass, in which
Article ZClasses are managed.
> In your case, I think you can do everything you need by just placing all
> of your articles in a Folder. If the folder was called 'Articles' you
> could do very simple iterative manipulations using the <dtml-in> tag.
>
> <ul>
> <dtml-in Articles>
> <li><a href="<dtml-var absolute_url>"><dtml-var title_or_id></a><br>
> <dtml-var sequence-item size=200></li>
> </dtml-in>
> </ul>
If you use ZClasses, this is a view of the ArticleFolder.
> This will print a link to each article, showing 200 characters of the
> objects body (This assumes your article objects are DTML Documents).
I would say that the representation is the task of the Article itself
and only partly of the ArticleFolder.
The article should be able to create different view on itself based on
what type of content it contains. If the Article is html, use the HTML_View,
and it it is structured text, the Article uses the Structured_Text_View.
> As an added hook point, you can write a DTML method that you pass the
> object to:
>
> <dtml-in Articles>
> <dtml-var "displayArticle(_['sequence-item'])">
> </dtml-in>
This view method can be placed in an ArticleFolder ZClass.
> If you place Articles and displayArticle in your root folder, then they
> will be accessable from anywhere in your Zope, all objects in the root
> folder are acquireable from all objects in Zope (note, when you drop to
> python, you have to play by the rules of the Acquisition mechanism).
I don't think it is very nice to clutter the root folder with all kinds
if views. It is much nicer to have the views in the appropriate
ZClasses.
> > It is also a requirement of this site that it can
> > display previous editions of the web site. For that I would
> > like to be
> > able to invoke my headlines in such a way that it could
> > generate different
> > headlines depending on which issue of the news publication
> > was desired.
>
> Here the catalog can help you. If all of your article objects are
> cataloged in a ZCatalog object, then you can do a very fast range search
> over all of the objects' creation dates.
> This is used on the Zope site
> on the advanced search page when you pull down the combo box to do a
> range search of objects created after a certain fixed point in the past
> (day, week, month, year, ever).
If your Articles are ZClasses, then you can perform a Catalog search
for all ZClasses with meta_type "Article".
You can also search for all ArticleFolders. This is best if you create
one ArticleFolder for each issue of your Newspaper.
> The problem is that as your articles change, you need to keep cataloging
> and recataloging them so that the catalog tracks any changes in the
> object.
> This is where things get tricky and you start developing an
> application, because you need your own kind of object to do that. This
> is when you should investigate ZClasses. There's a couple how-tos on
> the Zope site on how to make your own kind of catalog aware objects.
The ZClasses Article and ArticleFolder would be ZCatalogAware, and when changed
they can update the Catalog automatically.
> > Any tips on how I might structure my content (basically news
> > articles)
As I said, you would have an ArticleFolder per edition, or per week or
month.
> and
> > how my presentation layer might be able to utilize the
> > content would be
> > appreciated.
The presentation is handled by the ArticleFolder Views and the Article
Views.
> Make sure that all your major components are seperated from each other
> and use each other without strange dependencies (like assuming a path to
> a component, why assume when it can be acquired?).
You should make the ArticleFolder intelligent, and the Article dumb.
The Article only knows how to provide representations of itself, and
the ArticleFolder is responsible for managing the Articles inside.
> Keep collections of
> similar objects in folders by themselves.
Just like Michel says.
> It is generally a good idea
> to keep methods related to certain types of objects in the same place as
> the folder that contains those objects.
With ZClasses you don't have these problems.
> Use your root folder wisely, Luke.
Don't use the root folder, Luke :-)
The ideas I have described here are already used by the ZDP-Tools, which
I have written for the Zope Documentation Project together with Tom
Deprez. http://zdp.zope.org:8080/ZDP/
The site is currently down, so you'll have to check back later.
I would like to discuss the design with you, so if you are interested,
contact me personally or maybe just add your comments on the ZDP-Tools
right on the zdp.zope.org:8080/ZDP/projects/zdptools/ in the
Comments Section.
Greetings,
Maik Röder
roeder@berg.net