[Grok-dev] grokproject: paster support in trunk now

Kim Luong kim.luong at oit.gatech.edu
Thu Dec 11 15:13:05 EST 2008

Michael Haubenwallner wrote:
> Wichert Akkerman wrote:
>> Previously Michael Haubenwallner wrote:
>>> Derek Richardson wrote:
>>>> Michael Haubenwallner wrote:
>>>>> Derek Richardson wrote:
>>>>> Hi Derek, i just changed the trunk to make configuration files use
>>>>> absolute paths. Starting the instance from different directories and
>>>>> paste configs should work now.
>>>>> One thing to remember: startup.py assumes that .ini and zope.conf files
>>>>> are in the same folder (global_config['here'], thats the location of the
>>>>> paster .ini file). If you want to change that behaviour please let me
>>>>> know. The zope.conf file could be read as well from the package/etc folder.
>>>> Would it be possible to have the location of the zope.conf file 
>>>> configurable in the paster.ini so that it defaults to the same location 
>>>> as paster.ini but could be manually set to be at a different location? 
>>>> That seems like the perfect solution, to me.
>>> Decoupled paster .ini and zope.conf locations in trunk now.
>>> There is a global default 'zope_conf' now in the ini file. It is preset
>>> to the ini file directory: %(here)s . Change its path to the zope.conf
>>> folder if different.
>> Why not point that to the file itself, instead of to a directory? That
>> would allow people to use different filenames, or do multiple
>> deployments of the same app and put the conffiles in the same directory.
>> Levels of indirection are fine, but there has to be a good reason for
>> them :)
>> Wichert.
> Good idea, done.
> Thanks
> Michael

Hi, I'm working with Derek. We tried to use the change and have two 
different grok applications running in the same paste ini file. To do 
this  we had to change startup.py to look for zope_conf in the local 
config before the global config. While there, we also added a hard coded 
fall back to the template so if zope_conf is not defined in either the 
local or global config, it looks for it in the etc directory of the 
directory grokproject created. The patch for this is below.

However, our paste pipeline is currently directing requests to the URLs 
/tco and /invoice, which are each mapped to a different grok application 
, to only one of the grok applications. In other words, /tco should go 
to the tco application and /invoice should go to the invoice 
application; currently, we seeing both /tco and /invoice going to the 
tco application, which is the first of the two applications defined in 
our paster ini.

Do you expect that this is a problem with our paste pipeline? Or can we 
not run multiple grok instances in a single paste pipeline? If the 
second, we think it is valuable to have this capability before grok 1.0 
beta 1 because we know of no way to map (in a paste ini file) arbitrary 
URLs to different grok applications running in a single grok instance. 
Of course, if this is possible, we'd be happy to simply know how. :)

Kim (diff below)

Index: startup.py_tmpl
--- startup.py_tmpl	(revision 93857)
+++ 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)

@@ -32,4 +33,4 @@

      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)

More information about the Grok-dev mailing list