mako-1.3.10+ds1/ 0000775 0001750 0001750 00000000000 15053257076 011724 5 ustar zigo zigo mako-1.3.10+ds1/README.rst 0000664 0001750 0001750 00000002663 14775736353 013434 0 ustar zigo zigo =========================
Mako Templates for Python
=========================
Mako is a template library written in Python. It provides a familiar, non-XML
syntax which compiles into Python modules for maximum performance. Mako's
syntax and API borrows from the best ideas of many others, including Django
templates, Cheetah, Myghty, and Genshi. Conceptually, Mako is an embedded
Python (i.e. Python Server Page) language, which refines the familiar ideas
of componentized layout and inheritance to produce one of the most
straightforward and flexible models available, while also maintaining close
ties to Python calling and scoping semantics.
Nutshell
========
::
<%inherit file="base.html"/>
<%
rows = [[v for v in range(0,10)] for row in range(0,10)]
%>
% for row in rows:
${makerow(row)}
% endfor
<%def name="makerow(row)">
% for name in row:
| ${name} | \
% endfor
%def>
Philosophy
===========
Python is a great scripting language. Don't reinvent the wheel...your templates can handle it !
Documentation
==============
See documentation for Mako at https://docs.makotemplates.org/en/latest/
License
========
Mako is licensed under an MIT-style license (see LICENSE).
Other incorporated projects may be licensed under different licenses.
All licenses allow for non-commercial and commercial use.
mako-1.3.10+ds1/CHANGES 0000664 0001750 0001750 00000000263 14775736353 012732 0 ustar zigo zigo =====
MOVED
=====
Please see:
/docs/changelog.html
/docs/build/changelog.rst
or
https://docs.makotemplates.org/en/latest/changelog.html
for the current CHANGES.
mako-1.3.10+ds1/setup.py 0000664 0001750 0001750 00000000046 14775736353 013450 0 ustar zigo zigo from setuptools import setup
setup()
mako-1.3.10+ds1/examples/ 0000775 0001750 0001750 00000000000 14775736353 013554 5 ustar zigo zigo mako-1.3.10+ds1/examples/wsgi/ 0000775 0001750 0001750 00000000000 14775736353 014525 5 ustar zigo zigo mako-1.3.10+ds1/examples/wsgi/htdocs/ 0000775 0001750 0001750 00000000000 14775736353 016011 5 ustar zigo zigo mako-1.3.10+ds1/examples/wsgi/htdocs/index.html 0000664 0001750 0001750 00000000152 14775736353 020004 0 ustar zigo zigo <%
%>
<%inherit file="root.html"/>
This is index.html
c is ${c is not UNDEFINED and c or "undefined"}
mako-1.3.10+ds1/examples/wsgi/run_wsgi.py 0000664 0001750 0001750 00000004650 14775736353 016741 0 ustar zigo zigo #!/usr/bin/python
import cgi
import mimetypes
import os
import posixpath
import re
from mako import exceptions
from mako.lookup import TemplateLookup
root = "./"
port = 8000
lookup = TemplateLookup(
directories=[root + "templates", root + "htdocs"],
filesystem_checks=True,
module_directory="./modules",
# even better would be to use 'charset' in start_response
output_encoding="ascii",
encoding_errors="replace",
)
def serve(environ, start_response):
"""serves requests using the WSGI callable interface."""
fieldstorage = cgi.FieldStorage(
fp=environ["wsgi.input"], environ=environ, keep_blank_values=True
)
d = dict([(k, getfield(fieldstorage[k])) for k in fieldstorage])
uri = environ.get("PATH_INFO", "/")
if not uri:
uri = "/index.html"
else:
uri = re.sub(r"^/$", "/index.html", uri)
if re.match(r".*\.html$", uri):
try:
template = lookup.get_template(uri)
except exceptions.TopLevelLookupException:
start_response("404 Not Found", [])
return [str.encode("Cant find template '%s'" % uri)]
start_response("200 OK", [("Content-type", "text/html")])
try:
return [template.render(**d)]
except:
return [exceptions.html_error_template().render()]
else:
u = re.sub(r"^\/+", "", uri)
filename = os.path.join(root, u)
if os.path.isfile(filename):
start_response("200 OK", [("Content-type", guess_type(uri))])
return [open(filename, "rb").read()]
else:
start_response("404 Not Found", [])
return [str.encode("File not found: '%s'" % filename)]
def getfield(f):
"""convert values from cgi.Field objects to plain values."""
if isinstance(f, list):
return [getfield(x) for x in f]
else:
return f.value
extensions_map = mimetypes.types_map.copy()
def guess_type(path):
"""return a mimetype for the given path based on file extension."""
base, ext = posixpath.splitext(path)
if ext in extensions_map:
return extensions_map[ext]
ext = ext.lower()
if ext in extensions_map:
return extensions_map[ext]
else:
return "text/html"
if __name__ == "__main__":
import wsgiref.simple_server
server = wsgiref.simple_server.make_server("", port, serve)
print("Server listening on port %d" % port)
server.serve_forever()
mako-1.3.10+ds1/examples/wsgi/templates/ 0000775 0001750 0001750 00000000000 14775736353 016523 5 ustar zigo zigo mako-1.3.10+ds1/examples/wsgi/templates/root.html 0000664 0001750 0001750 00000000120 14775736353 020365 0 ustar zigo zigo
hi
${next.body()}