Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-lazar committed Feb 16, 2023
1 parent 53dc0e8 commit 9b55458
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## v3.0.0 (2023-02-14)
## v3.0.0 (unreleased)

This version pulls in some long overdue dependency updates and adds
support for the latest versions of Flask and Python.
Expand Down
5 changes: 3 additions & 2 deletions demo/run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def demo_form(field):

# Check if there was a new field added to the request
request_query = request.args.to_dict()

if field in form_fields:
request_query[field] = request.environ["SEARCH_TEXT"]

Expand All @@ -167,7 +168,7 @@ def demo_form(field):
if name in request_query:
lines.append(f"{description:<13}: {request_query[name]}")
else:
url = url_for("demo_form", field=name, **request_query)
url = url_for("demo_form", _external=False, field=name, **request_query)
lines.append(gopher.menu.query(f"{description:<13}:", url))

# Add the buttons at the bottom of the form
Expand All @@ -177,7 +178,7 @@ def demo_form(field):
else:
lines.append("clear")
if request_query.keys() == form_fields.keys():
url = url_for("demo_form", field="submit", **request_query)
url = url_for("demo_form", _external=False, field="submit", **request_query)
lines.append(gopher.menu.dir("submit", url))
else:
lines.append("submit")
Expand Down
18 changes: 12 additions & 6 deletions flask_gopher/flask_gopher.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@

from .__version__ import __version__

"""
Shortcut for gopher.menu
"""
menu = cast("GopherMenu", LocalProxy(lambda: current_app.extensions["gopher"].menu))

@LocalProxy
def _menu():
"""
Shortcut for gopher.menu
"""
return current_app.extensions["gopher"].menu


menu = cast("GopherMenu", _menu)


def render_menu(*lines):
Expand Down Expand Up @@ -483,8 +489,8 @@ def menu(self):
if not hasattr(g, "_flask_gopher_menu"):
host = request.environ["SERVER_NAME"]
port = request.environ["SERVER_PORT"]
g._flask_gopher_menu = self.menu_class(host, port)
return g._flask_gopher_menu
setattr(g, "_flask_gopher_menu", self.menu_class(host, port))
return getattr(g, "_flask_gopher_menu")

def render_menu(self, *lines):
"""
Expand Down

0 comments on commit 9b55458

Please sign in to comment.