Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
865cc5ce
Commit
865cc5ce
authored
Jun 28, 1999
by
cathi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved string output for Request. Added new form types in HTTPRequest.py.
parent
7da93bf1
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
333 additions
and
70 deletions
+333
-70
lib/python/ZPublisher/BaseRequest.py
lib/python/ZPublisher/BaseRequest.py
+4
-3
lib/python/ZPublisher/HTTPRequest.py
lib/python/ZPublisher/HTTPRequest.py
+282
-67
lib/python/ZPublisher/cgi.py
lib/python/ZPublisher/cgi.py
+47
-0
No files found.
lib/python/ZPublisher/BaseRequest.py
View file @
865cc5ce
...
...
@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
from
string
import
join
,
split
,
find
,
rfind
,
lower
,
upper
from
urllib
import
quote
...
...
@@ -181,8 +181,9 @@ class BaseRequest:
return
result
def
__str__
(
self
):
return
join
(
map
(
lambda
item
:
"%s:
\
t
%s"
%
item
,
self
.
items
()),
"
\
n
"
)
L1
=
self
.
items
()
L1
.
sort
()
return
join
(
map
(
lambda
item
:
"%s:
\
t
%s"
%
item
,
L1
),
"
\
n
"
)
__repr__
=
__str__
...
...
lib/python/ZPublisher/HTTPRequest.py
View file @
865cc5ce
This diff is collapsed.
Click to expand it.
lib/python/ZPublisher/cgi.py
View file @
865cc5ce
...
...
@@ -562,6 +562,45 @@ def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
If true, errors raise a ValueError exception.
"""
dict
=
{}
for
name_value
in
name_value_pairs
:
nv
=
string
.
splitfields
(
name_value
,
'='
)
if
len
(
nv
)
!=
2
:
if
strict_parsing
:
raise
ValueError
,
"bad query field: %s"
%
`name_value`
continue
name
=
urllib
.
unquote
(
string
.
replace
(
nv
[
0
],
'+'
,
' '
))
value
=
urllib
.
unquote
(
string
.
replace
(
nv
[
1
],
'+'
,
' '
))
if
len
(
value
)
or
keep_blank_values
:
if
dict
.
has_key
(
name
):
dict
[
name
].
append
(
value
)
else
:
dict
[
name
]
=
[
value
]
return
dict
def
parse_qsl
(
qs
,
keep_blank_values
=
0
,
strict_parsing
=
0
):
"""Parse a query given as a string argument.
Arguments:
qs: URL-encoded query string to be parsed
keep_blank_values: flag indicating whether blank values in
URL encoded queries should be treated as blank strings.
A true value inicates that blanks should be retained as
blank strings. The default false value indicates that
blank values are to be ignored and treated as if they were
not included.
strict_parsing: flag indicating what to do with parsing errors.
If false (the default), errors are silently ignored.
If true, errors raise a ValueError exception.
Returns a list, as God intended.
"""
name_value_pairs
=
string
.
splitfields
(
qs
,
'&'
)
r
=
[]
for
name
,
value
in
parse_qsl
(
qs
,
keep_blank_values
,
strict_parsing
):
if
len
(
value
)
or
keep_blank_values
:
if
dict
.
has_key
(
name
):
...
...
@@ -592,6 +631,7 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
"""
name_value_pairs
=
string
.
splitfields
(
qs
,
'&'
)
r
=
[]
for
name_value
in
name_value_pairs
:
nv
=
string
.
splitfields
(
name_value
,
'='
)
if
len
(
nv
)
!=
2
:
...
...
@@ -958,10 +998,17 @@ class FieldStorage:
def
read_urlencoded
(
self
):
"""Internal: read data in query string format."""
qs
=
self
.
fp
.
read
(
self
.
length
)
self
.
list
=
list
=
[]
append
=
list
.
append
for
key
,
value
in
parse_qsl
(
qs
,
self
.
keep_blank_values
,
self
.
strict_parsing
):
append
(
MiniFieldStorage
(
key
,
value
))
self
.
list
=
list
=
[]
for
key
,
value
in
parse_qsl
(
qs
,
self
.
keep_blank_values
,
self
.
strict_parsing
):
list
.
append
(
MiniFieldStorage
(
key
,
value
))
self
.
skip_lines
()
FieldStorageClass
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment