Skip to content
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

Make debug=true handling actually use openlibrary.yml config #224

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions infogami/infobase/_dbstore/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def recentchanges(self, limit=100, offset=0, **kwargs): # noqa: PLR0912
order = 't.created DESC'
wheres = ["1 = 1"]

if offset < 0:
offset = 0
offset = max(offset, 0)

if (key := kwargs.pop('key', None)) is not None:
thing_id = self.get_thing_id(key)
Expand Down
6 changes: 2 additions & 4 deletions infogami/infobase/readquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def make_query(store, query, prefix=""):
q.prefix = prefix
q.offset = common.safeint(query.pop('offset', None), 0)
q.limit = common.safeint(query.pop('limit', 20), 20)
if q.limit > 1000:
q.limit = 1000
q.limit = min(q.limit, 1000)
sort = query.pop('sort', None)

nested = prefix != ""
Expand Down Expand Up @@ -256,8 +255,7 @@ def make_versions_query(store, query):

q.offset = common.safeint(query.pop('offset', None), 0)
q.limit = common.safeint(query.pop('limit', 20), 20)
if q.limit > 1000:
q.limit = 1000
q.limit = min(q.limit, 1000)
q.sort = query.pop('sort', '-created')

columns = [
Expand Down
5 changes: 2 additions & 3 deletions infogami/utils/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import web

from infogami.utils import storage, template
from infogami.utils import features, storage, template
from infogami.utils.markdown import markdown

# macros loaded from disk
Expand Down Expand Up @@ -104,8 +104,7 @@ def call_macro(name, args):
macro_string = name + "(" + args + ")"
result = macro_eval(macro, macro_string)
except Exception as e:
i = web.input(_method="GET", debug="false")
if i.debug.lower() == "true":
if features.is_enabled("debug"):
raise
result = f"{name} failed with error: <pre>{web.websafe(str(e))}</pre>"
import traceback
Expand Down
5 changes: 2 additions & 3 deletions infogami/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import web

from infogami.utils import storage
from infogami.utils import features, storage

# There are some backward-incompatible changes in web.py 0.34 which makes Infogami fail.
assert web.__version__ != "0.34", "Please pip install --upgrade web.py"
Expand Down Expand Up @@ -163,8 +163,7 @@ def saferender(templates, *a, **kw):
except Exception as e:
# help to debug template errors.
# when called with debug=true, the debug error is displayed.
i = web.input(_method='GET', debug="false")
if i.debug.lower() == "true":
if features.is_enabled("debug"):
raise

from . import delegate, view # avoids circular imports
Expand Down
Loading