Re: [Zope3-Users] z3c.baseregistry question

2007-04-02 Thread Stephan Richter
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):
>
>  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: [, ]

Where do you regsiter this event subscriber?

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

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 
. But the code is good here.

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

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
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.baseregistry question

2007-03-27 Thread eXt
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):

  

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: [, ]

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



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

   

  

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


-- 
Jakub Wisniowski
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.baseregistry question

2007-03-22 Thread Stephan Richter
On Thursday 22 March 2007 07:29, eXt wrote:
> I'd like to register things like default skin or logout adapter
> () per application
> (my local site), not per Zope instance via overrides.zcml. Is it possible
> to use z3c.baseregistry for that?

Yes, this is what we are using it for. ;-)

> 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.

> One more thing - how should I install z3c.baseregistry after I
> checkouted it from the repository? There is only 'src' folder and no
> 'setup.py' script. I manually copied files but I suppose it is not a
> preffered way of installing it.

That is one way of doing it. In our projects we usually use the following 
structure:

Project/
  src/
z3c/
  basergistry/
project/
  Zope3

You then need some custom scripts to register src/ and Zope3/src everywhere in 
the Python path. Not too bad though.

Others use buildout and eggs (which I really need to look at too).

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users