Re: [Repoze-dev] ZCA registry confusion

2010-04-13 Thread Chris McDonough
On 4/13/10 7:17 PM, Chris McDonough wrote:
 On 4/13/10 7:03 PM, Iain Duncan wrote:
 Hi, I have some custom middleware that is intended to use the same ZCA
 registry as my bfg app. I've altered the run.py in the bfg app to tell
 it to use the global site manager, and the middleware looks up utilities
 by doing

 self.gsm = getGlobalSiteManager()
 self.gsm.queryUtility etc

 This is all working fine for the app. But recently my isolated tests
 stopped working. I know the environment is different now, new bfg, newer
 release of zope.component, but I can't figure out how to make them work
 anymore. I want the following to give me a registry populated from the
 configure.zcml file in the pets packag, but instead it seems to be empty:

 def test_gsm_setup(self):
 test_gsm_setup - test that we can setup a zca registry from the model
 file
 import pets
 xmlconfig.file('configure.zcml', package=pets)
 gsm = getGlobalSiteManager()
 assert sm._utility_registrations


 Use the pattern from
 http://docs.repoze.org/bfg/1.2/narr/unittesting.html#test-set-up-and-tear-down
 instead, but extend it just like you did for your BFG app at startup
 time, e.g.:

 def test_gsm_setup(self):
 from repoze.bfg.configuration import Configurator
 from zope.component import getGlobalSiteManager
 gsm = getGlobalSiteManager()
 self.config.begin()
 self.config.load_zcml('pets:configure.zcml')
 self.config.end()
 assert gsm._utility_registrations


 - C

Crap.  There should be a self.config = Configurator() in there.  Hopefully you 
get the idea.

- C


-- 
Chris McDonough
Agendaless Consulting, Fredericksburg VA
The repoze.bfg Web Application Framework Book: http://bfg.repoze.org/book
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] ZCA registry confusion

2010-04-13 Thread Chris McDonough
On 4/13/10 9:22 PM, Iain Duncan wrote:

 Ok, I think a better way to phrase mine is:

 - is it safe and/or reasonable to use the repoze.bfg configurator to
 setup up the global ZCA registry for non-bfg uses?

It is not reasonable.  It is possible, though.

- C
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] ZCA registry confusion

2010-04-13 Thread Iain Duncan
On Tue, Apr 13, 2010 at 7:10 PM, Chris McDonough chr...@plope.com wrote:

 On 4/13/10 9:22 PM, Iain Duncan wrote:


 Ok, I think a better way to phrase mine is:

 - is it safe and/or reasonable to use the repoze.bfg configurator to
 setup up the global ZCA registry for non-bfg uses?


 It is not reasonable.  It is possible, though.

 - C


Does anyone have the time to point me at how I should do it? I've been
googling quite a bit but don't seem to be finding much in the way of
examples of setting up a zca registry from zcml files. From what I could
tell, the code I posted looked like it ought to populate the global site
manager, but when I do:

xmlconfig.file('configure.zcml', package=pets)
gsm = getGlobalSiteManager()
# or
sm = getSiteManager()

both gsm and sm seem to be empty.

thanks
iain
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev