Mercurial > p > roundup > code
annotate roundup/cgi/engine_chameleon.py @ 8478:ed4ef394d5d6
doc: initial attempt to document setup of pgp support for email.
Used an AI assistant to help write this. Basic gpg commands seem to
work, but I have not tested this totally. Docs basically follow the
setup used for pgp testing in the test suite.
It looks like roundup accepts signed emails as well as encrypted
and signed emails. But it does not generate signed emails.
Also it looks like there is no PGP support for alternate email
addresses. Only primary addresses can do PGP emails.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 15 Nov 2025 16:59:24 -0500 |
| parents | 310e19beba3e |
| children |
| rev | line source |
|---|---|
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
1 """Templating engine adapter for the Chameleon.""" |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
2 |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
3 __docformat__ = 'restructuredtext' |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
4 |
|
4720
fd72576e07ed
API break: rename Templates to Loader for zopetal and chameleon
anatoly techtonik <techtonik@gmail.com>
parents:
4719
diff
changeset
|
5 import chameleon |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
6 |
|
5418
55f09ca366c4
Python 3 preparation: StringIO.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5416
diff
changeset
|
7 from roundup.cgi.templating import context, TALLoaderBase |
|
5416
56c9bcdea47f
Python 3 preparation: unicode.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4749
diff
changeset
|
8 from roundup.anypy.strings import s2u |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
9 |
|
6063
4d20d8251bf2
flake8 whitespace; removed unused import os.path.
John Rouillard <rouilj@ieee.org>
parents:
5418
diff
changeset
|
10 |
|
4749
0421390b3094
templating: Move common TAL methods to TALLoaderBase class
anatoly techtonik <techtonik@gmail.com>
parents:
4740
diff
changeset
|
11 class Loader(TALLoaderBase): |
|
7775
b8e63e65d9a8
chore: replace use of dir with template_dir.
John Rouillard <rouilj@ieee.org>
parents:
6063
diff
changeset
|
12 def __init__(self, template_dir): |
|
b8e63e65d9a8
chore: replace use of dir with template_dir.
John Rouillard <rouilj@ieee.org>
parents:
6063
diff
changeset
|
13 self.template_dir = template_dir |
|
7790
ac0802452818
fix: typo in var name inan unused (mostly) chameleon engine.
John Rouillard <rouilj@ieee.org>
parents:
7775
diff
changeset
|
14 self.loader = chameleon.PageTemplateLoader(template_dir) |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
15 |
|
4740
fe9568a6cbd6
Untangle template selection logic from template loading functionality.
anatoly techtonik <techtonik@gmail.com>
parents:
4739
diff
changeset
|
16 def load(self, tplname): |
|
7999
310e19beba3e
fix: report filename if template file is invalid
John Rouillard <rouilj@ieee.org>
parents:
7790
diff
changeset
|
17 try: |
|
310e19beba3e
fix: report filename if template file is invalid
John Rouillard <rouilj@ieee.org>
parents:
7790
diff
changeset
|
18 src, filename = self._find(tplname) |
|
310e19beba3e
fix: report filename if template file is invalid
John Rouillard <rouilj@ieee.org>
parents:
7790
diff
changeset
|
19 except TypeError as e: |
|
310e19beba3e
fix: report filename if template file is invalid
John Rouillard <rouilj@ieee.org>
parents:
7790
diff
changeset
|
20 raise ValueError("Unable to load template file basename: %s: %s" % ( |
|
310e19beba3e
fix: report filename if template file is invalid
John Rouillard <rouilj@ieee.org>
parents:
7790
diff
changeset
|
21 tplname, e)) |
|
310e19beba3e
fix: report filename if template file is invalid
John Rouillard <rouilj@ieee.org>
parents:
7790
diff
changeset
|
22 |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
23 return RoundupPageTemplate(self.loader.load(src)) |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
24 |
|
6063
4d20d8251bf2
flake8 whitespace; removed unused import os.path.
John Rouillard <rouilj@ieee.org>
parents:
5418
diff
changeset
|
25 |
|
4635
45ac4cd1a381
Fixes for RoundupPageTemplate in engine_chameleon.py.
Cheer Xiao <xiaqqaix@gmail.com>
parents:
4587
diff
changeset
|
26 class RoundupPageTemplate(object): |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
27 def __init__(self, pt): |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
28 self._pt = pt |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
29 |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
30 def render(self, client, classname, request, **options): |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
31 c = context(client, self, classname, request) |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
32 c.update({'options': options}) |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
33 |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
34 def translate(msgid, domain=None, mapping=None, default=None): |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
35 result = client.translator.translate(domain, msgid, |
|
6063
4d20d8251bf2
flake8 whitespace; removed unused import os.path.
John Rouillard <rouilj@ieee.org>
parents:
5418
diff
changeset
|
36 mapping=mapping, |
|
4d20d8251bf2
flake8 whitespace; removed unused import os.path.
John Rouillard <rouilj@ieee.org>
parents:
5418
diff
changeset
|
37 default=default) |
|
5416
56c9bcdea47f
Python 3 preparation: unicode.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4749
diff
changeset
|
38 return s2u(result) |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
39 |
|
4635
45ac4cd1a381
Fixes for RoundupPageTemplate in engine_chameleon.py.
Cheer Xiao <xiaqqaix@gmail.com>
parents:
4587
diff
changeset
|
40 output = self._pt.render(None, translate, **c) |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
41 return output.encode(client.charset) |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
42 |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
43 def __getitem__(self, name): |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
44 return self._pt[name] |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
45 |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
46 def __getattr__(self, name): |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
47 return getattr(self._pt, name) |
