cherrypy-foundation 1.0.0a6__py3-none-any.whl → 1.0.0a8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cherrypy_foundation/components/Flash.jinja +13 -0
- cherrypy_foundation/error_page.py +1 -1
- cherrypy_foundation/tests/templates/test_flash.html +8 -0
- cherrypy_foundation/tests/test_error_page.py +6 -0
- cherrypy_foundation/tests/test_flash.py +61 -0
- cherrypy_foundation/tests/test_form.py +4 -4
- {cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/METADATA +1 -1
- {cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/RECORD +11 -8
- {cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/WHEEL +0 -0
- {cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/licenses/LICENSE.md +0 -0
- {cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{# def messages, floating=False #}
|
|
2
|
+
<div {{ attrs.render(class="flash-messages") }}>
|
|
3
|
+
{% for message, level in messages %}
|
|
4
|
+
<div class="alert alert-{{'danger' if level == 'error' else level }} alert-dismissible fade show"
|
|
5
|
+
role="alert">
|
|
6
|
+
{{ message }}
|
|
7
|
+
<button type="button"
|
|
8
|
+
class="btn-close"
|
|
9
|
+
data-bs-dismiss="alert"
|
|
10
|
+
aria-label="Close"></button>
|
|
11
|
+
</div>
|
|
12
|
+
{% endfor %}
|
|
13
|
+
</div>
|
|
@@ -63,7 +63,7 @@ def error_page(status='', message='', traceback='', version=''):
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
# Replace message by generic one for 404. Default implementation leak path info.
|
|
66
|
-
if status == '404 Not Found':
|
|
66
|
+
if status == '404 Not Found' and cherrypy.serving.request.path_info in message:
|
|
67
67
|
message = 'Nothing matches the given URI'
|
|
68
68
|
|
|
69
69
|
# Check expected response type.
|
|
@@ -29,6 +29,10 @@ class Root:
|
|
|
29
29
|
|
|
30
30
|
@cherrypy.expose
|
|
31
31
|
def not_found(self):
|
|
32
|
+
raise cherrypy.NotFound()
|
|
33
|
+
|
|
34
|
+
@cherrypy.expose
|
|
35
|
+
def not_found_custom(self):
|
|
32
36
|
raise cherrypy.HTTPError(404, message='My error message')
|
|
33
37
|
|
|
34
38
|
@cherrypy.expose
|
|
@@ -60,6 +64,8 @@ class ErrorPageTest(helper.CPWebCase):
|
|
|
60
64
|
|
|
61
65
|
@parameterized.expand(
|
|
62
66
|
[
|
|
67
|
+
('/not_found', '<p>Nothing matches the given URI</p>'),
|
|
68
|
+
('/not_found_custom', '<p>My error message</p>'),
|
|
63
69
|
('/html_error', '<p>My error message</p>'),
|
|
64
70
|
('/json_error', '{"message": "json error message", "status": "400 Bad Request"}'),
|
|
65
71
|
('/text_error', 'text error message'),
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# CherryPy Foundation
|
|
2
|
+
# Copyright (C) 2025 IKUS Software
|
|
3
|
+
#
|
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
import importlib
|
|
17
|
+
from unittest import skipUnless
|
|
18
|
+
|
|
19
|
+
import cherrypy
|
|
20
|
+
from cherrypy.test import helper
|
|
21
|
+
|
|
22
|
+
import cherrypy_foundation.tools.jinja2 # noqa
|
|
23
|
+
from cherrypy_foundation.flash import flash, get_flashed_messages
|
|
24
|
+
|
|
25
|
+
HAS_JINJAX = importlib.util.find_spec("jinjax") is not None
|
|
26
|
+
|
|
27
|
+
env = cherrypy.tools.jinja2.create_env(
|
|
28
|
+
package_name=__package__,
|
|
29
|
+
globals={'get_flashed_messages': get_flashed_messages},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@cherrypy.tools.sessions()
|
|
34
|
+
@cherrypy.tools.jinja2(env=env)
|
|
35
|
+
class Root:
|
|
36
|
+
|
|
37
|
+
@cherrypy.expose
|
|
38
|
+
@cherrypy.tools.jinja2(template='test_flash.html')
|
|
39
|
+
def index(self):
|
|
40
|
+
flash('default flash message', level='info')
|
|
41
|
+
return {}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@skipUnless(HAS_JINJAX, reason='Required jinjax')
|
|
45
|
+
class FormTest(helper.CPWebCase):
|
|
46
|
+
default_lang = None
|
|
47
|
+
interactive = False
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def setup_server(cls):
|
|
51
|
+
cherrypy.tree.mount(Root(), '/')
|
|
52
|
+
|
|
53
|
+
def test_get_flash(self):
|
|
54
|
+
# Given a page returning a flash message
|
|
55
|
+
# When querying the page that include this form
|
|
56
|
+
self.getPage("/")
|
|
57
|
+
self.assertStatus(200)
|
|
58
|
+
# Then page display the message.
|
|
59
|
+
self.assertInBody('test-flash')
|
|
60
|
+
self.assertInBody('<div class="alert alert-info alert-dismissible fade show"')
|
|
61
|
+
self.assertInBody('default flash message')
|
|
@@ -109,8 +109,8 @@ class FormTest(helper.CPWebCase):
|
|
|
109
109
|
'<input class="form-check-input" container-class="col-sm-6" id="persistent" label-attr="FOO" name="persistent" type="checkbox" value="y">'
|
|
110
110
|
)
|
|
111
111
|
self.assertInBody('<label attr="FOO" class="form-check-label" for="persistent">Remember me</label>')
|
|
112
|
-
# 5. check submit button
|
|
113
|
-
self.assertInBody('<div attr="BAR"
|
|
114
|
-
self.
|
|
115
|
-
'<input class="btn-primary float-end btn" container-attr="BAR" container-class="col-sm-6" id="submit" name="submit" type="submit" value="Login">'
|
|
112
|
+
# 5. check submit button (regex matches because class could have different order with jinjax<=0.57)
|
|
113
|
+
self.assertInBody('<div attr="BAR"')
|
|
114
|
+
self.assertMatchesBody(
|
|
115
|
+
'<input class="(btn-primary ?|float-end ?|btn ?){3}" container-attr="BAR" container-class="col-sm-6" id="submit" name="submit" type="submit" value="Login">'
|
|
116
116
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cherrypy_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
cherrypy_foundation/error_page.py,sha256=
|
|
2
|
+
cherrypy_foundation/error_page.py,sha256=rAFr4Oc_xjIQn7sQbng5Z0r-bgqy8T3LwtCa2tv7M3A,3248
|
|
3
3
|
cherrypy_foundation/flash.py,sha256=fFRbutUX6c1lVHqjehmO9y98dJgmfNCjhd76t2mth2s,1542
|
|
4
4
|
cherrypy_foundation/form.py,sha256=8c9dO0o47sK3CBosTkGXoVRtzNQwY0aw0vNZfTqmhvo,3994
|
|
5
5
|
cherrypy_foundation/logging.py,sha256=YIOK5ZAZLCv52YDdP66yBYpEX1C336JnI3wnrTKl1Lw,3468
|
|
@@ -14,6 +14,7 @@ cherrypy_foundation/components/Field.css,sha256=CtOkvIbix7ykrOKLJxQJLJsWfEwFqfdu
|
|
|
14
14
|
cherrypy_foundation/components/Field.jinja,sha256=R-ZUm88XXOb3zi_hysTuwFUCGGR67A59P4TT5d1Qo_o,3152
|
|
15
15
|
cherrypy_foundation/components/Field.js,sha256=SFixZ62WlLq7SSCEazMAGhSnc9EnQ1wg6PZX4ayO6ZE,2047
|
|
16
16
|
cherrypy_foundation/components/Fields.jinja,sha256=UDu1txwMguvr7dyga9PXepEhFvz9C6ZvchBnhQCWgHI,318
|
|
17
|
+
cherrypy_foundation/components/Flash.jinja,sha256=COy44drQsXpbZajjJS4w_9NMPYFdMfUNdfhd7SbFdYA,442
|
|
17
18
|
cherrypy_foundation/components/Icon.jinja,sha256=Z1RGYBg5xlDEoUy3glqb_k_LEjkJHeCxQXqDEvWzEF4,135
|
|
18
19
|
cherrypy_foundation/components/SideBySideMultiSelect.css,sha256=_poMY9O8rvDsOh01pQLf9qtg1Gm4eCM2HsM_ekC5zkk,503
|
|
19
20
|
cherrypy_foundation/components/SideBySideMultiSelect.jinja,sha256=sud1WP-6JzuP7ZLRr-JQqvgMRWZRlXvxUJfguFr_klk,478
|
|
@@ -90,10 +91,12 @@ cherrypy_foundation/plugins/tests/test_ldap.py,sha256=7EhFvhxwDCCBoNlAD5XpZxLtKv
|
|
|
90
91
|
cherrypy_foundation/plugins/tests/test_scheduler.py,sha256=I-ZuQhMvCCvqFDwukwsyz_UkdJJ8JSLTkAanUo24GCE,3564
|
|
91
92
|
cherrypy_foundation/plugins/tests/test_smtp.py,sha256=qs5yezIpSXkBmLmFlqckfPW7NmntHZxQjDSkdQG_dNE,4183
|
|
92
93
|
cherrypy_foundation/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
|
-
cherrypy_foundation/tests/test_error_page.py,sha256=
|
|
94
|
-
cherrypy_foundation/tests/
|
|
94
|
+
cherrypy_foundation/tests/test_error_page.py,sha256=8yLK8OGbJIdUjilFIHMNBZadLKHrXnD6KSmQ3Da4LaQ,2399
|
|
95
|
+
cherrypy_foundation/tests/test_flash.py,sha256=JqZDAgazlNnP3HcPFmFOWbPeDDMzc6z5fHNe-pBTin0,1976
|
|
96
|
+
cherrypy_foundation/tests/test_form.py,sha256=sWsPWyXwAVkCeP5t0qIHc0Oi32Zi3kztoQ_wlDR9STc,4326
|
|
95
97
|
cherrypy_foundation/tests/test_passwd.py,sha256=gC5O4yhHyU1YRYuDc0pG0T_5zvrG2qrr6P822iyK3Rg,1956
|
|
96
98
|
cherrypy_foundation/tests/test_url.py,sha256=W-RTKQuxYS2KXxCYTTtnKcxfdP9F6Fp3QKY_sBTnBmE,6434
|
|
99
|
+
cherrypy_foundation/tests/templates/test_flash.html,sha256=MyOPsHQX97TB30sbKrbG3tagKDyvV8OVKp-UOrw7REc,187
|
|
97
100
|
cherrypy_foundation/tests/templates/test_form.html,sha256=sm-n2cYvih2vbDE4Y8kkERSoulnKAbwoefbzBggMMnA,189
|
|
98
101
|
cherrypy_foundation/tests/templates/test_url.html,sha256=Rb6NokHEduMHAXO8P6EduMMHXuNzJGN5Of2OF4fSWns,502
|
|
99
102
|
cherrypy_foundation/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -120,8 +123,8 @@ cherrypy_foundation/tools/tests/locales/fr/LC_MESSAGES/messages.po,sha256=6_Sk9I
|
|
|
120
123
|
cherrypy_foundation/tools/tests/templates/test_jinja2.html,sha256=v9AHxksbBvzE7sesPqE61HMhsvU4juXt3E0ZQo-zXVQ,190
|
|
121
124
|
cherrypy_foundation/tools/tests/templates/test_jinja2_i18n.html,sha256=98S51dgG7Vb4rvMZNZvomw1D9pBiM4g6pdlxAgvrxXA,373
|
|
122
125
|
cherrypy_foundation/tools/tests/templates/test_jinjax.html,sha256=NT19UaUzm8FRKOIc6H6HNGPDJU6KATnakd8zf3BCeAs,153
|
|
123
|
-
cherrypy_foundation-1.0.
|
|
124
|
-
cherrypy_foundation-1.0.
|
|
125
|
-
cherrypy_foundation-1.0.
|
|
126
|
-
cherrypy_foundation-1.0.
|
|
127
|
-
cherrypy_foundation-1.0.
|
|
126
|
+
cherrypy_foundation-1.0.0a8.dist-info/licenses/LICENSE.md,sha256=trSLYs5qlaow_bBwsLTRKpmTXsXzFksM_YUCMqrgAJQ,35149
|
|
127
|
+
cherrypy_foundation-1.0.0a8.dist-info/METADATA,sha256=7aXt2rwg_HACqXWiWHeFxkJN0wrVNWylVJZbf9M-L-8,2022
|
|
128
|
+
cherrypy_foundation-1.0.0a8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
129
|
+
cherrypy_foundation-1.0.0a8.dist-info/top_level.txt,sha256=B1vQPTLYhpKJ6W0JkRCWyAf8RPcnwJWdYxixv75-4ew,20
|
|
130
|
+
cherrypy_foundation-1.0.0a8.dist-info/RECORD,,
|
|
File without changes
|
{cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
{cherrypy_foundation-1.0.0a6.dist-info → cherrypy_foundation-1.0.0a8.dist-info}/top_level.txt
RENAMED
|
File without changes
|