diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 8e60946..7d93cec 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1953,21 +1953,20 @@ class PhotoDB( self.sql.commit() @classmethod - def closest_photodb(cls, *args, **kwargs): + def closest_photodb(cls, path, *args, **kwargs): ''' Starting from the cwd and climbing upwards towards the filesystem root, look for an existing Etiquette data directory and return the PhotoDB object. If none exists, raise exceptions.NoClosestPhotoDB. ''' - cwd = pathclass.cwd() + starting = path - path = cwd while True: if path.with_child(constants.DEFAULT_DATADIR).is_dir: break parent = path.parent if path == parent: - raise exceptions.NoClosestPhotoDB(cwd.absolute_path) + raise exceptions.NoClosestPhotoDB(starting.absolute_path) path = parent path = path.with_child(constants.DEFAULT_DATADIR) diff --git a/frontends/etiquette_cli.py b/frontends/etiquette_cli.py index 116269c..ff7da59 100644 --- a/frontends/etiquette_cli.py +++ b/frontends/etiquette_cli.py @@ -30,7 +30,7 @@ def find_photodb(): pass # If this raises, main will catch it. - photodb = etiquette.photodb.PhotoDB.closest_photodb(log_level=LOG_LEVEL) + photodb = etiquette.photodb.PhotoDB.closest_photodb(cwd, log_level=LOG_LEVEL) photodbs[cwd] = photodb return photodb diff --git a/frontends/etiquette_flask/etiquette_flask_dev.py b/frontends/etiquette_flask/etiquette_flask_dev.py index 8554bdf..b4577ce 100644 --- a/frontends/etiquette_flask/etiquette_flask_dev.py +++ b/frontends/etiquette_flask/etiquette_flask_dev.py @@ -58,7 +58,7 @@ def etiquette_flask_launch( site.localhost_only = True try: - backend.common.init_photodb(log_level=LOG_LEVEL) + backend.common.init_photodb(path=pathclass.cwd(), log_level=LOG_LEVEL) except etiquette.exceptions.NoClosestPhotoDB as exc: pipeable.stderr(exc.error_message) pipeable.stderr('Try `etiquette_cli.py init` to create the database.') diff --git a/frontends/etiquette_flask/etiquette_flask_prod.py b/frontends/etiquette_flask/etiquette_flask_prod.py index 535adb4..424e000 100644 --- a/frontends/etiquette_flask/etiquette_flask_prod.py +++ b/frontends/etiquette_flask/etiquette_flask_prod.py @@ -6,6 +6,8 @@ gunicorn etiquette_flask_prod:site --bind "0.0.0.0:PORT" --access-logfile "-" ''' import werkzeug.middleware.proxy_fix +from voussoirkit import pathclass + import backend backend.site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(backend.site.wsgi_app) @@ -13,4 +15,4 @@ backend.site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(backend.site.wsgi site = backend.site site.debug = False -backend.common.init_photodb() +backend.common.init_photodb(path=pathclass.cwd()) diff --git a/frontends/etiquette_repl.py b/frontends/etiquette_repl.py index de82f4c..e25390e 100644 --- a/frontends/etiquette_repl.py +++ b/frontends/etiquette_repl.py @@ -10,6 +10,7 @@ import sys import traceback from voussoirkit import interactive +from voussoirkit import pathclass from voussoirkit import pipeable from voussoirkit import vlogging @@ -41,7 +42,7 @@ def erepl_argparse(args): global P try: - P = etiquette.photodb.PhotoDB.closest_photodb(log_level=LOG_LEVEL) + P = etiquette.photodb.PhotoDB.closest_photodb(pathclass.cwd(), log_level=LOG_LEVEL) except etiquette.exceptions.NoClosestPhotoDB as exc: pipeable.stderr(exc.error_message) pipeable.stderr('Try `etiquette_cli.py init` to create the database.')