no pyramid
from stringexchange import make_exchange, function_call_emitter
exchange = make_exchange(function_call_emitter)
template = """f(a, {}, b)""".format(exchange.subscribe("args"))
p = exchange.publisher("args")
p.publish("x")
p.publish("y\n")
p.publish("z")
output = exchange.emit(template)
assert output == "f(a, x, y, z, b)"
on pyramid
file structure
onpyramid.py
top.html
onpyramid.py
# -*- coding:utf-8 -*-
## onpyramid.py
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
import os.path
def top_view(request):
js = request.string_exchange.publisher("js")
css = request.string_exchange.publisher("css")
return {"css": css, "js": js}
if __name__ == '__main__':
here = os.path.dirname(os.path.abspath(__file__))
settings = {"mako.directories": here,
"pyramid.reload_templates": True}
config = Configurator(settings=settings)
config.include("pyramid_mako")
config.include("stringexchange") # !!
config.add_mako_renderer(".html")
config.add_route('top', '/')
config.add_view(top_view, route_name='top', renderer="top.html")
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
top.html
## top.html
<html>
<head>
${request.string_exchange.subscribe("css", emit="newline", iterator="unique")}
</head>
<body>
<!-- foo widget -->
<% js.publish('<script src="base.js"></script>') %>
<% js.publish('<script src="foo.js"></script>') %>
<h1>foo</h1>
foo content
<!-- boo widget -->
<% js.publish('<script src="base.js"></script>') %>
<% js.publish('<script src="boo.js"></script>') %>
<% css.publish('<link href="widget.boo.css"></link>') %>
<h1>boo</h1>
<ul>
<li>boo0</li>
<li>boo1</li>
<li>boo2</li>
</ul>
${request.string_exchange.subscribe("js", "newline", iterator="unique")}
</body>
</html>
output
$ python demo/onpyramid.py &
$ curl http://localhost:8080
<html>
<head>
<link href="widget.boo.css"></link>
</head>
<body>
<!-- foo widget -->
<h1>foo</h1>
foo content
<!-- boo widget -->
<h1>boo</h1>
<ul>
<li>boo0</li>
<li>boo1</li>
<li>boo2</li>
</ul>
<script src="base.js"></script>
<script src="foo.js"></script>
<script src="boo.js"></script>
</body>
</html>
Metadata
Release files for stringexchange 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stringexchange-0.1.tar.gz | 4.9 kB | Without provenance | Details for stringexchange-0.1.tar.gz |
Release files / stringexchange-0.1.tar.gz
| Download URL | stringexchange-0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b68942d685993ebe9751a6d537171d3e8d39007e78b5e5ce5d1fe58a436b2cab
|
|
BLAKE2b-256 checksum How to use checksums |
dc5f4dee6823478718460a80060b57084da51dc8c799e8664091c1a053f5d62e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for stringexchange 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.