On Sat, Feb 02, 2013 at 12:58:02PM -0800, Mikołaj Siedlarek wrote: > Hi, > > Is there any way I could use zope.components ZCML configuration in my > Pyramid project *not losing* the ability to run multiple application in one > process? > > I know I could just use `Configurator.hook_zca` and use global components > site, but this wouldn't work for multiple apps in one process. > > I tried to use zope.configuration ZCML utilities on Pyramid configurator > and it's attributes but they seem incompatible. There is some class in > `pyramid.config` called `ActionState` that kind of resembles > `ConfigurationMachine` from `zope.configuration`, but not enough to use > `zope.configuration.xmlconfig` stuff on it. > > Am I missing something?
I do something similar with pretty hacky code like this. Basically loading the adapters registered in the ZCML into the configurator's registry rather than the global one: from pyramid.threadlocal import manager from pyramid.config import Configurator from zope.configuration import xmlconfig def set_up_app(): config = Configurator() config.hook_zca() manager.push(dict(registry=config.registry)) try: xmlconfig.file(site_zcml) finally: manager.pop() Of course, not all zcml commands are created equal and some will register components globally despite these gymnastics. <tales:expressiontype> is one I know that does not work. <adapter> and <utiltiy> from zope.component 3.9.3 and up do work. http://docs.pylonsproject.org/projects/pyramid_zcml/en/latest/ would be another option, but I'm not familiar with it. > > Thanks, > Mikołaj > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To post to this group, send email to pylons-discuss@googlegroups.com. > Visit this group at http://groups.google.com/group/pylons-discuss?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- Brian Sutherland -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss?hl=en. For more options, visit https://groups.google.com/groups/opt_out.