Well,

since my daemon is run from a controller in the context of a request,

could I retrieve the name of the .ini file from somewhere (config?)?

So I can pass it as an argument to the daemon.

Then it will get by itself what it needs from ini file.

Thanks

On Oct 27, 6:47 pm, Wyatt Baldwin <[email protected]> wrote:
> On Oct 27, 8:26 am, neurino <[email protected]> wrote:
>
>
>
>
>
> > I also experience the same problem:
>
> > i have a deamon that access the same db of the app,
> > it performs long import tasks that would hang the server.
>
> > It's located in the upper "myapp" directory:
>
> > myapp
> >     |
> >     - myapp
> >     - mydeamon.py
>
> > this way I can do a "import myapp" from the daemon for example to use
> > some modules under myapp.lib
>
> > I wish I can get db `sqlalchemy.url` string
>
> > But also the ini file path so I can do in daemon:
>
> > logging.config.fileConfig('whatever.ini')
>
> > and have the daemon write on the same log file of myapp.
>
> > I did:
>
> > from pylons import config
> > dbFile = config['app_conf']['sqlalchemy.url'] #it works from
> > controllers
>
> > but I get:
> > ...
> >   File "/root/my-applications/sensor/sensor/lib/importutils.py", line
> > 87, in dbConnect
> >     bdFile = config['app_conf']['sqlalchemy.url']
> >   File "/root/my-applications/mydevenv/lib/python2.6/site-packages/
> > Paste-1.7.5.1-py2.6.egg/paste/registry.py", line 146, in __getitem__
> >     return self._current_obj()[key]
> > KeyError: 'app_conf'
>
> > Thanks for your support.
>
> You can't use `pylons.config` at the module level (generally
> speaking), because it's only set in the context of a request.
>
> So, you can access it from within in a model class method in the
> context of a request. Another option is to call a `model.init(config)`
> function from `load_environment` to set up the model.
>
> I think that latter is preferable, since I like to keep my model
> separate from any particular application environment (e.g., Web,
> desktop, etc).
>
> Oh, and an aside: the usual way to access config items is like this:
> `config['sqlalchemy.url']`. You shouldn't need the `['app_conf']`.
>
>
>
> > On Oct 26, 7:44 pm, Jan Koprowski <[email protected]> wrote:
>
> > > Hi,
>
> > >   In which section You put Your directive in ini file? If in
> > > [app:main] You should make in Your model file:
>
> > >   from pylons import config
> > >   config['my.directive']
>
> > >   where ini file contain:
>
> > >   my.directive = foobar
>
> > > On Tue, Oct 26, 2010 at 6:15 PM, Juliusz Gonera <[email protected]> wrote:
> > > > Hi,
>
> > > > I have a model called Gallery that needs to create some directories. The
> > > > path where it should create them is stored in the .ini file. I wanted to
> > > > access it but I keep getting KeyError. Does it mean that I can not 
> > > > access
> > > > config in the model? Should I simply make a Python file in the config
> > > > directory of my project and store the app config there?
>
> > > > Regards,
>
> > > > --
> > > > Juliusz Gonera
> > > >http://juliuszgonera.com/
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "pylons-discuss" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected].
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/pylons-discuss?hl=en.
>
> > > --
>
> > > ><> Jan Koprowski

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to