[Zope3-Users] z3c.baseregistry question

eXt news.crumbler at gmail.com
Tue Mar 27 15:47:14 EDT 2007


Dnia piątek, 23 marca 2007 03:15, Stephan Richter napisał:
> >         If so I'll be glad to see any introduction or code example of how
> > to use this package. I'm a bit lost after reading baseregistry's doctests.
> 
> Can you be more specific? I think you can get the gist of things by looking 
at 
> the ZCML snippets in the main README.txt file and how to register a base 
> registry in the browser/README.txt file.
I read these but I must have missed something, because I can't get my code to 
work. 
Below are the details. What I try to accomplish is to define default skin for 
my local site instead of global overrides.zcml.

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')

2. registered my custom registry (configure.zcml):

  <utility
	component=".site.custom"
	provides="zope.component.interfaces.IComponents"
	name="custom" />

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

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

4. placed my_product-overrides.zcml in instance's package-includes:

<include package="my_product" file="override.zcml" />

5. placed override.zcml in my_product's root folder:

   <registerIn registry=".site.custom">
    <browser:defaultSkin name="MyProductSkin" />
  </registerIn>

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


-- 
Jakub Wisniowski


More information about the Zope3-users mailing list