seitime-frappe/frappe/website/page_renderers/base_renderer.py
Ankush Menat 81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30

27 lines
680 B
Python

import frappe
from frappe.website.utils import build_response
class BaseRenderer:
def __init__(self, path=None, http_status_code=None):
self.headers = None
self.http_status_code = http_status_code or 200
if not path:
path = frappe.local.request.path
self.path = path.strip("/ ")
self.basepath = ""
self.basename = ""
self.name = ""
self.route = ""
self.file_dir = None
def can_render(self):
raise NotImplementedError
def render(self):
raise NotImplementedError
def build_response(self, data, http_status_code=None, headers=None):
return build_response(
self.path, data, http_status_code or self.http_status_code, headers or self.headers
)