[Zope3-Users] z3c.baseregistry question

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Apr 2 09:07:52 EDT 2007


On Tuesday 27 March 2007 15:47, eXt wrote:
> Simplified structure of files in the filesystem:
>
> my_product
>
>                  |- site.py
>                  |- configure.zcml
>                  |- overrides.zcml
>
> What I did:
> 1. I created custom registry instance (site.py - file where my local site
> is defined):
>
>    from z3c.baseregistry import baseregistry
>    import zope.component
>    custom =
> baseregistry.BaseComponents(zope.component.globalSiteManager, 'custom')

That looks good.

> 2. registered my custom registry (configure.zcml):
>
>   <utility
> 	component=".site.custom"
> 	provides="zope.component.interfaces.IComponents"
> 	name="custom" />

Yep.

> 3. set my local site __bases__ (site.py):
>
> def setSiteManagerWhenAdded(site, event):
>
>     site.setSiteManager(LocalSiteManager(site))
>     sm = site.getSiteManager()
>
>     custom = zope.component.getUtility(IComponents, name='custom')
>     sm.__bases__ += (custom,)
>
>     bases = list(sm.__bases__)
>     bases.reverse()
>     sm.__bases__ = bases

You are correct here. You have to make sure the "custom" registry is the first 
one. BTW, you can always verify the order in the ZMI by clicking on "Bases" 
after entering the site manager.

I assume that everything below is just for debugging, right?

>     #what is sm.__bases__ ?
>     print sm.__bases__
>     #it prints: [<BaseComponents custom>, <LocalSiteManager ++etc++site>]

Where do you regsiter this event subscriber?

> 4. placed my_product-overrides.zcml in instance's package-includes:
>
> <include package="my_product" file="override.zcml" />

btw, calling the file override.zcml will give people the wrong idea what it 
does. The term override.zcml is usually reserved for use with 
<includeOverrides>. But the code is good here.

> 5. placed override.zcml in my_product's root folder:
>
>    <registerIn registry=".site.custom">
>     <browser:defaultSkin name="MyProductSkin" />
>   </registerIn>

Looks good. 

> There are no errors when I start my Z3 instance, but the above defaultSkin
> directive is ignored. What is wrong here?

To me everything looks fine. Make sure that

(1) all ZCML files are loaded; just insert invalid directives temporarly.
(2) the event subscriber is executed.
(3) the base is really there after you added a new site. (Use ZMI for example)
(4) With the debugger try to query for the default skin and see if you get the 
right one back.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list