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

Changed SAMBRO homepage 500 error #1494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 15 additions & 10 deletions modules/templates/SAMBRO/controllers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from datetime import datetime, timedelta
from gluon.messageboxhandler import Tkinter

try:
import json # try stdlib (Python 2.6)
Expand Down Expand Up @@ -45,11 +46,15 @@ def __call__(self):
layer = current.db(query).select(ftable.layer_id,
limitby=(0, 1)
).first()

skipMap = True
try:
layer_id = layer.layer_id
skipMap = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention: not pascalCase, but all_lower_case with underscore as word separator

except:
current.log.error("Cannot find Layer for Map")
layer_id = None
Tkinter.messagebox.showinfo("Error", "Cannot find Layer for Map")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message should be shown on the client-side, not on the server as normally there's no user there (hence the log message here). Besides, Tkinter is an optional module, and (for the same reason) not normally installed on the server.

The message can be shown either as HTML in place of the map (simply by putting it into the _map variable), or as response.error.



feature_resources = [{"name" : T("Alerts"),
"id" : "search_results",
Expand All @@ -59,15 +64,15 @@ def __call__(self):
# We activate in callback after ensuring URL is updated for current filter status
"active" : False,
}]

_map = current.gis.show_map(callback='''S3.search.s3map()''',
catalogue_layers=True,
collapsed=True,
feature_resources=feature_resources,
save=False,
search=True,
toolbar=True,
)
if not skipMap:
_map = current.gis.show_map(callback='''S3.search.s3map()''',
catalogue_layers=True,
collapsed=True,
feature_resources=feature_resources,
save=False,
search=True,
toolbar=True,
)
output["_map"] = _map

# Filterable List of Alerts
Expand Down