Allen Fowler wrote:
>>> FWIW:
>>>
>>> When using relative paths I got extra ../../ terms, so I changed
>> join_relative() to:
>>> def join_relative(base, path):
>>> return os.path.normpath(os.path.join(script_dir(base), path))
>>>
>>>
>>> Seems to work...
>>
>> Yeah, good catch ... looks grea
> >
> > FWIW:
> >
> > When using relative paths I got extra ../../ terms, so I changed
> join_relative() to:
> >
> > def join_relative(base, path):
> > return os.path.normpath(os.path.join(script_dir(base), path))
> >
> >
> > Seems to work...
>
>
> Yeah, good catch ... looks great,
Allen Fowler wrote:
>
>
>> Martin Walsh
>>
>
>> Allen Fowler wrote:
>>> As a follow-up question, how do give my modules stored under ./lib access
>>> to
>> the data in my ConfigParser object? (For instance, database connection
>> string,
>> storage path, etc.)
>>> I guess a global ConfigPa
Allen Fowler wrote:
>
>
>
>> Something like this ...
>>
>> # lib/mypaths.py
>> # --
>>
>> import os
>>
>> def script_path(base):
>> return os.path.realpath(os.path.abspath(base))
>>
>> def script_dir(base):
>> return os.path.dirname(script_path(base))
>>
>> def join_relative(
"Allen Fowler" wrote
For an object that needs many settings, what about passing
in an instance of ConfigParser? (Or should I extract the
settings to a dict, first?)
Personally I usually extract an ini type settings to either global
variables or an object or a dict at start up., I then pa
>
> Something like this ...
>
> # lib/mypaths.py
> # --
>
> import os
>
> def script_path(base):
> return os.path.realpath(os.path.abspath(base))
>
> def script_dir(base):
> return os.path.dirname(script_path(base))
>
> def join_relative(base, path):
> return os.pa
> Martin Walsh
>
> Allen Fowler wrote:
> >
>
> >
> > As a follow-up question, how do give my modules stored under ./lib access
> > to
> the data in my ConfigParser object? (For instance, database connection
> string,
> storage path, etc.)
> >
> > I guess a global ConfigParser object w
> > Assuming the application could be invoked in odd ways that may alter the
> notion of the current working directory, how do I unambiguously find the
> absolute path to the current python source file? (So I can load the nearby
> .ini)
>
> I use a helper function that calculates the absol
Allen Fowler wrote:
>
>
> As a follow-up question, how do give my modules stored under ./lib access to
> the data in my ConfigParser object? (For instance, database connection
> string, storage path, etc.)
>
> I guess a global ConfigParser object would work, but that seems wrong.
>
And yet
Allen Fowler wrote:
>
>
>
>>> What is the recommended way to configure my application find the various
>> database and/or configuration files it needs?
>>
>> Recommemded by whom? A lot depends on the OS. Apple for example have one set
>> of
>> recommendations for MacOS, Windows has another an
Allen Fowler wrote:
What is the recommended way to configure my application find the various
database and/or configuration files it needs?
Recommemded by whom? A lot depends on the OS. Apple for example have one set of
recommendations for MacOS, Windows has another and Linux has several
> > What is the recommended way to configure my application find the various
> database and/or configuration files it needs?
>
> Recommemded by whom? A lot depends on the OS. Apple for example have one set
> of
> recommendations for MacOS, Windows has another and Linux has several to
> cho
"Allen Fowler" wrote
What is the recommended way to configure my application
find the various database and/or configuration files it needs?
Recommemded by whom? A lot depends on the OS. Apple for
example have one set of recommendations for MacOS, Windows
has another and Linux has several to
Hello,
What is the recommended way to configure my application find the various
database and/or configuration files it needs?
For instance my folder layout:
/path_to_app/app.py
/path_to_app/lib/
/path_to_app/database/
/path_to_app/config/
/path_to_app/photos
and so on. (app.py being th
14 matches
Mail list logo