-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use default database path for location.Database() #4
base: master
Are you sure you want to change the base?
Conversation
This is a naive sketch of the idea, since I've never written a Python module in C before. Basically, I propose that there is a constructor `location.Database()` which uses a built-in default path, e.g. _/var/lib/location/database.db_ e.g. the value of `@databasedir@`.
Hello 8, what is the motivation for this change? |
We want to use the Python library in cross-platform code that is packaged
(Debian, Homebrew, pip, etc). We don't want to manage the database file
locations in the scripts that use the Python module, and the libloc build system
already has code to manage that location.
|
I understand your point, but I am hesitant to implement this since the behaviour of the Python bindings would be different from C and Perl. If we would do this, we should have the library behave as similarly as possible for all. |
I think this proposed API makes sense regardless of the language. Since there
is already a default location in the build system, it should be offered as an
option in the APIs.
|
How about we export the default location as a constant which can then be passed to the Database() class? |
Exporting the path as a constant seems fine, but that wouldn't replace just
having `Database()`. I think good APIs have sensible defaults. This clearly is
a sensible default.
|
I agree. Just calling Database() is much neater. I just consider it being more of a low-level function which should not be called. I would prefer something like "location.open()" or "location.open(path)". |
I don't know this whole API, so I don't know what would fit in best. My goal is
to have a sensible default for the database path, wherever that makes the most
sense. Our current implementation uses
`location.Database('/var/lib/location/database.db`)`, that's why I made the
change there.
|
How does this look to you? https://git.ipfire.org/?p=location/libloc.git;a=commitdiff;h=a0e8d454c80bf39d935b95c5fd53611db7cbb0e9 BTW, we don't intend to use GitHub PRs. We have documented this somewhere, but it is easily overlooked. So, I will delete this repository on here soon. |
That looks great! Sorry about starting this on GitHub, no problem about removing it. |
This is a naive sketch of the idea, since I've never written a Python module in C before. Basically, I propose that there is a constructor
location.Database()
which uses a built-in default path, e.g. /var/lib/location/database.db e.g. the value of@databasedir@
.