[Zope3-Users] Re: Configuring a package to use a file in buildout

Darryl Cousins darryl at darrylcousins.net.nz
Fri Nov 23 15:50:15 EST 2007


Hi Jürgen,

Thanks! I'll try that out.

Darryl

On Fri, 2007-11-23 at 11:00 +0100, Jürgen Kartnaller wrote:
> In your buildout you do :
> 
> [instance]
> recipe = zc.zope3recipes:instance
> application = app
> address = 8080
> zope.conf =
> 
>    <product-config my-config-name>
>      storagedir ${buildout:directory}/parts/log
>    </product-config>
> 
> 
> If you need the log dir precreated you do :
> 
> [extfiledir]
> recipe = lovely.recipe:mkdir
> path = parts/log
> 
> 
> To access the product config from python :
> 
> from zope.app.appsetup.product import getProductConfiguration
> 
> config = getProductConfiguration('my-config-name')
> if config is not None:
>      path = config.get('logpath')
> 
> 
> Use your utility name as "my-config-name".
> 
> 
> Jürgen
> 
> Darryl Cousins wrote:
> > Hi,
> > 
> > I have a custom logger in a package registered with utility
> > 
> > <zope:utility  factory=".logger.MyLogger" name="logger" />
> > 
> > In the code it sets itself a logfile to write to, up to now that has
> > been in a 'log' directory in the package itself.
> > 
> > Now I want to use a log file which is in the buildout of the
> > application. How could I go about finding that directory from python
> > code in the package?
> > 
> > The only route that I have come up with so far is to write a
> > meta:directive which I can use to register the logging utility with a
> > file path. Something like:
> > 
> >   <meta:directive
> >       namespace="http://namespaces.zope.org/rdb"
> >       name="provideLogger"
> >       schema=".zcml.IProvideLoggerDirective"
> >       handler=".zcml.loggerhandler"
> >       />
> > 
> > Which I could use like
> > 
> >   <provideLogger component=".logger.MyLogger"
> >                  log="/path/to/log/file" />
> > 
> > But there may be a better/easier way. Suggestions?
> > 
> > Regards,
> > Darryl
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



More information about the Zope3-users mailing list