[Zope3-Users] Changing "homepage" view/content

Stéphane Brunet stbru at teksavvy.com
Sun Aug 21 16:56:41 EDT 2005


Stéphane Brunet wrote:

> Hello,
>
> I was wondering how to change the homepage view, just like in the 
> worldcookery.com website (In fact, I installed the "wcsite" package to 
> try it). On the official site, cliking on the "Home" (or top) link 
> goes to a welcome page containing customized content rather than on 
> the default list of objects contained in the top folder.
>
> How can I reproduce this behaviour on my own site ?
>
> Thank you!
>
> Stéphane
>
Answering to my own question: it is just a matter of configuration…

The code of Worldcookery.com website (see wcsite-1.1.tgz in the download 
area) adds a view in order to provide a more specific interface, 
IWCSite, to the top folder which provides ISite interface. The 
configure.zcml file for the whole package contains the following part:

<browser:page
name="makeWCSite.html"
for="zope.app.site.interfaces.ISite"
class=".browser.MakeWCSite"
attribute="makeWCSite"
permission="zope.ManageServices"
/>

which links to the following piece of code in browser.py file:

class MakeWCSite(BrowserView):

def makeWCSite(self):
site = removeSecurityProxy(self.context)
directlyProvides(site, IWCSite, providedBy(site))
self.request.response.redirect('.')

So when invoking e.g. http://localhost:8080/makeWCsite.html, the 
makeWCSite function adds the IWCSite interface to the list of interfaces 
provided by the top folder (look at the introspector view of the top 
folder before and after).

Thanks to the other part of configure.zcml for the whole package :

<browser:page
name="index.html"
for=".interfaces.IWCSite"
class=".browser.WCSiteView"
template="site.pt"
permission="zope.View"
/>

a custom view for the IWCSite objects is registered. The site.pt file 
does the rest of the job.

I hope that it can help other newcomers like me... ;-)

Any idea how to the same in a more generic way ?

Regards,

Stéphane



More information about the Zope3-users mailing list