Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
request.app_name = app_name
ret = func(*func_args, **func_kwargs)
if isinstance(ret, dict):
response.headers["Content-Type"] = "application/json"
ret = dumps(ret)
return ret
except HTTP as http:
response.status = http.status
return ""
except bottle.HTTPResponse:
raise
except Exception:
logging.error(traceback.format_exc())
try:
ticket = ErrorStorage().log(request.app_name, get_error_snapshot())
except Exception:
logging.error(traceback.format_exc())
ticket = "unknown"
return error_page(
500, button_text=ticket, href="/_dashboard/ticket/" + ticket
)
def error_ticket(ticket_uuid):
return dict(ticket=ErrorStorage().get(ticket_uuid=ticket_uuid))
import requests
import py4web
from py4web import __version__, action, abort, request, response, redirect, Translator
from py4web.core import Reloader, dumps, ErrorStorage, Session, Fixture
from pydal.validators import CRYPT
from yatl.helpers import BEAUTIFY
from .utils import *
MODE = os.environ.get("PY4WEB_DASHBOARD_MODE", "none")
FOLDER = os.environ["PY4WEB_APPS_FOLDER"]
APP_FOLDER = os.path.dirname(__file__)
T_FOLDER = os.path.join(APP_FOLDER, "translations")
T = Translator(T_FOLDER)
error_storage = ErrorStorage()
db = error_storage.db
session = Session()
class Logged(Fixture):
def __init__(self, session):
self.__prerequisites__ = [session]
self.session = session
def on_request(self):
user = self.session.get("user")
if not user or not user.get("id"):
abort(403)
session_secured = action.uses(Logged(session))