Skip to content

Commit

Permalink
FieldStorage implementation based on legacy cgi.FieldStorage
Browse files Browse the repository at this point in the history
* Some small linter fixes
* Some small type fixes
  • Loading branch information
ondratu committed Oct 12, 2024
1 parent 7db05c9 commit bb2a77b
Show file tree
Hide file tree
Showing 14 changed files with 826 additions and 208 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
root = true

# elementary defaults
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = tab
indent_style = space
insert_final_newline = false
max_line_length = 80
tab_width = 4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
line_length = 79
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[MAIN]
load-plugins=pylint.extensions.no_self_use

[MESSAGES CONTROL]
disable = too-many-instance-attributes,
too-many-arguments,
too-many-positional-arguments
22 changes: 17 additions & 5 deletions examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def create(self, filename):
def log_request(req):
"""Log each request before processing."""
log.info("Before response")
log.info("Headers: %s", req.headers)
log.info("Data: %s", req.data)


Expand Down Expand Up @@ -395,15 +396,27 @@ def test_form(req):
'<input type="text" name="gx" value="3"><br/>',
'<input type="submit" name="btn" value="Send">'
'</form>',
"<h2>Post Form</h2>",
'<form method="post">',
"<h2>Post Form multipart/form-data</h2>",
'<form method="post" enctype="multipart/form-data">',
'<input type="text" name="fname" value="Ondřej"><br/>',
'<input type="text" name="fsurname" value="Tůma"><br/>',
'<input type="text" name="fx" value="8">'
'<input type="text" name="fx" value="7">'
'<input type="text" name="fx" value="6"><br/>',
'<textarea name="fbody">Some\ntext</textarea><br/>'
'<input type="submit" name="btn" value="Send">'
'</form>',
"<h2>Post Form application/x-www-form-urlencoded</h2>",
'<form method="post" enctype="application/x-www-form-urlencoded">',
'<input type="text" name="pname" value="Ondřej"><br/>',
'<input type="text" name="psurname" value="Tůma"><br/>',
'<input type="text" name="px" value="8">'
'<input type="text" name="px" value="7">'
'<input type="text" name="px" value="6"><br/>',
'<textarea name="fbody">Some\ntext</textarea><br/>'
'<input type="submit" name="btn" value="Send">'
'</form>',

"<h2>Variables</h2>",
"<table>") + \
tuple("<tr><td>%s:</td><td>%s</td></tr>" %
Expand Down Expand Up @@ -517,10 +530,9 @@ def not_found(req):


@app.error_handler(ValueError)
def value_error_handler(req, error):
def value_error_handler(*_):
"""ValueError exception handler example."""
assert req
print("ValueError: ", error)
log.exception("ValueError")
raise HTTPException(state.HTTP_BAD_REQUEST)


Expand Down
Loading

0 comments on commit bb2a77b

Please sign in to comment.