zope_conf in paster config can only be global

Bug #320644 reported by Kim Luong
6
Affects Status Importance Assigned to Milestone
grok
Fix Released
Medium
Michael Haubenwallner

Bug Description

Michael Haubenwallner was kind enough to add zope_conf parameter to the paster config so that you can specify the location of the zope.conf. However, it only got added as a global parameter. This means that you can't specify different zope.conf for different applications. We would like grok to be able to handle different zope.conf for different applications. We have patched grok project so that it works for us and request that you roll our patch into subversion. svn diff follows signature.

Thanks,
Kim

Index: /srv/gp2/grokproject/template_paste/src/+package+/startup.py_tmpl
===================================================================
--- /srv/gp2/grokproject/template_paste/src/+package+/startup.py_tmpl (revision 94965)
+++ /srv/gp2/grokproject/template_paste/src/+package+/startup.py_tmpl (working copy)
@@ -5,8 +5,9 @@
 import zope.app.wsgi
 import zope.app.debug

-def application_factory(global_conf):
- zope_conf = os.path.join(global_conf['zope_conf'])
+def application_factory(global_conf, **local_conf):
+ conf_name = local_conf.get('zope_conf', global_conf.get('zope_conf', '${package_directory}/etc/zope.conf'))
+ zope_conf = os.path.join(conf_name)
     return zope.app.wsgi.getWSGIApplication(zope_conf)

 def interactive_debug_prompt(zope_conf='${package_directory}/etc/zope.conf'):
@@ -32,4 +33,4 @@

 def zdaemon_controller(zdaemon_conf='${package_directory}/etc/zdaemon.conf'):
     args = ['-C', zdaemon_conf] + sys.argv[1:]
- zdaemon.zdctl.main(args, options=None, cmdclass=ControllerCommands)
\ No newline at end of file
+ zdaemon.zdctl.main(args, options=None, cmdclass=ControllerCommands)

Revision history for this message
Martijn Faassen (faassen) wrote :

Michael, can you look into this?

Changed in grok:
assignee: nobody → d2m
importance: Undecided → Medium
milestone: none → 1.0
Revision history for this message
Uli Fouquet (uli-gnufix) wrote :

As we currently try to move startup.py away from application code itself I am afraid that a term like ``${package_directory}`` runs us into trouble.

Beside this I (yet) do not completely understand your use case. Could you provide some examples how you call different applications with the patch applied?

Revision history for this message
Michael Haubenwallner (d2m) wrote :

I think we really need to reorganize that part of app startup.

Martijn Faassen already suggested to move startup.py into a package on its own (like grok.startup) to move it out of app template creation process. I am working on this, hope you can join me.

Revision history for this message
Kim Luong (kim-luong) wrote : Re: [Bug 320644] Re: zope_conf in paster config can only be global

Michael,

I apologize for such a delayed response. In any cases, I'd be happy to help in any way I can. I must make a disclaimer that I'm very much a newbie. Let me know what I can do.

Thanks,

Kim

------------
Kim Luong
OIT - Academic and Research Technologies
Georgia Institute of Technology
258 Fourth Street, Rich Bldg, Rm 325
Atlanta, GA 30332-0700
<email address hidden>
404.385.1927

----- Original Message -----
From: "Michael Haubenwallner" <email address hidden>
To: "kim luong" <email address hidden>
Sent: Saturday, January 24, 2009 3:16:45 AM GMT -05:00 US/Canada Eastern
Subject: [Bug 320644] Re: zope_conf in paster config can only be global

I think we really need to reorganize that part of app startup.

Martijn Faassen already suggested to move startup.py into a package on
its own (like grok.startup) to move it out of app template creation
process. I am working on this, hope you can join me.

--
zope_conf in paster config can only be global
https://bugs.launchpad.net/bugs/320644
You received this bug notification because you are a direct subscriber
of the bug.

Status in grok: New

Bug description:
Michael Haubenwallner was kind enough to add zope_conf parameter to the paster config so that you can specify the location of the zope.conf. However, it only got added as a global parameter. This means that you can't specify different zope.conf for different applications. We would like grok to be able to handle different zope.conf for different applications. We have patched grok project so that it works for us and request that you roll our patch into subversion. svn diff follows signature.

Thanks,
Kim

Index: /srv/gp2/grokproject/template_paste/src/+package+/startup.py_tmpl
===================================================================
--- /srv/gp2/grokproject/template_paste/src/+package+/startup.py_tmpl (revision 94965)
+++ /srv/gp2/grokproject/template_paste/src/+package+/startup.py_tmpl (working copy)
@@ -5,8 +5,9 @@
 import zope.app.wsgi
 import zope.app.debug

-def application_factory(global_conf):
- zope_conf = os.path.join(global_conf['zope_conf'])
+def application_factory(global_conf, **local_conf):
+ conf_name = local_conf.get('zope_conf', global_conf.get('zope_conf', '${package_directory}/etc/zope.conf'))
+ zope_conf = os.path.join(conf_name)
     return zope.app.wsgi.getWSGIApplication(zope_conf)

 def interactive_debug_prompt(zope_conf='${package_directory}/etc/zope.conf'):
@@ -32,4 +33,4 @@

 def zdaemon_controller(zdaemon_conf='${package_directory}/etc/zdaemon.conf'):
     args = ['-C', zdaemon_conf] + sys.argv[1:]
- zdaemon.zdctl.main(args, options=None, cmdclass=ControllerCommands)
\ No newline at end of file
+ zdaemon.zdctl.main(args, options=None, cmdclass=ControllerCommands)

Revision history for this message
Uli Fouquet (uli-gnufix) wrote :

Michael -

maybe _you_ can tell me the use cases Kim talks about. Wouldn't it be sufficient to create alternative ini-files for different zope-confs?

Anyway, I'd be happy to assist with the 'external' startup.py. We can discuss this in the other thread:

  https://bugs.launchpad.net/grok/+bug/316799

Revision history for this message
Michael Haubenwallner (d2m) wrote :

added the local_conf option to the new grokcore.startup

Changed in grok:
status: New → Fix Committed
Changed in grok:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.