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
7c734bb2
Commit
7c734bb2
authored
Nov 13, 2001
by
matt@zope.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge lazy object support into REQUEST
parent
ed9971a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
lib/python/ZPublisher/BaseRequest.py
lib/python/ZPublisher/BaseRequest.py
+4
-1
lib/python/ZPublisher/HTTPRequest.py
lib/python/ZPublisher/HTTPRequest.py
+30
-3
No files found.
lib/python/ZPublisher/BaseRequest.py
View file @
7c734bb2
...
...
@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__
=
'$Revision: 1.4
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
2
$'
[
11
:
-
2
]
from
string
import
join
,
split
,
find
,
rfind
,
lower
,
upper
from
urllib
import
quote
...
...
@@ -197,6 +197,9 @@ class BaseRequest:
__getattr__
=
get
=
__getitem__
def
set_lazy
(
self
,
key
,
callable
):
pass
# MAYBE, we could do more, but let HTTPRequest do it
def
has_key
(
self
,
key
):
return
self
.
get
(
key
,
_marker
)
is
not
_marker
...
...
lib/python/ZPublisher/HTTPRequest.py
View file @
7c734bb2
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__version__
=
'$Revision: 1.5
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
import
re
,
sys
,
os
,
string
,
urllib
,
time
,
whrandom
,
cgi
from
string
import
lower
,
atoi
,
rfind
,
split
,
strip
,
join
,
upper
,
find
...
...
@@ -139,7 +139,7 @@ class HTTPRequest(BaseRequest):
The request object is a mapping object that represents a
collection of variable to value mappings. In addition, variables
are divided into f
our
categories:
are divided into f
ive
categories:
- Environment variables
...
...
@@ -159,6 +159,12 @@ class HTTPRequest(BaseRequest):
These are the cookie data, if present.
- Lazy Data
These are callables which are deferred until explicitly
referenced, at which point they are resolved and stored as
application data.
- Other
Data that may be set by an application object.
...
...
@@ -304,6 +310,7 @@ class HTTPRequest(BaseRequest):
self
.
form
=
{}
self
.
steps
=
[]
self
.
_steps
=
[]
self
.
_lazies
=
{}
################################################################
# Get base info first. This isn't likely to cause
...
...
@@ -891,13 +898,26 @@ class HTTPRequest(BaseRequest):
self
.
other
[
key
]
=
v
return
v
v
=
self
.
common
.
get
(
key
,
default
)
v
=
self
.
common
.
get
(
key
,
_marker
)
if
v
is
not
_marker
:
return
v
if
self
.
_lazies
:
v
=
self
.
_lazies
.
get
(
key
,
_marker
)
if
v
is
not
_marker
:
if
callable
(
v
):
v
=
v
()
self
[
key
]
=
v
# Promote lazy value
del
self
.
_lazies
[
key
]
return
v
if
default
is
not
_marker
:
return
default
raise
KeyError
,
key
__getattr__
=
__getitem__
def
set_lazy
(
self
,
key
,
callable
):
self
.
_lazies
[
key
]
=
callable
def
get
(
self
,
key
,
default
=
None
):
return
self
.
__getitem__
(
key
,
default
)
...
...
@@ -909,6 +929,7 @@ class HTTPRequest(BaseRequest):
def
keys
(
self
):
keys
=
{}
keys
.
update
(
self
.
common
)
keys
.
update
(
self
.
_lazies
)
for
key
in
self
.
environ
.
keys
():
if
(
isCGI_NAME
(
key
)
or
key
[:
5
]
==
'HTTP_'
)
and
\
...
...
@@ -942,6 +963,9 @@ class HTTPRequest(BaseRequest):
result
=
result
+
"</table><h3>cookies</h3><table>"
for
k
,
v
in
self
.
cookies
.
items
():
result
=
result
+
row
%
(
escape
(
k
),
escape
(
repr
(
v
)))
result
=
result
+
"</table><h3>lazy items</h3><table>"
for
k
,
v
in
self
.
_lazies
.
items
():
result
=
result
+
row
%
(
escape
(
k
),
escape
(
repr
(
v
)))
result
=
result
+
"</table><h3>other</h3><table>"
for
k
,
v
in
self
.
other
.
items
():
if
k
in
(
'PARENTS'
,
'RESPONSE'
):
continue
...
...
@@ -972,6 +996,9 @@ class HTTPRequest(BaseRequest):
result
=
result
+
"
\
n
COOKIES
\
n
\
n
"
for
k
,
v
in
self
.
cookies
.
items
():
result
=
result
+
row
%
(
k
,
repr
(
v
))
result
=
result
+
"
\
n
LAZY ITEMS
\
n
\
n
"
for
k
,
v
in
self
.
_lazies
.
items
():
result
=
result
+
row
%
(
k
,
repr
(
v
))
result
=
result
+
"
\
n
OTHER
\
n
\
n
"
for
k
,
v
in
self
.
other
.
items
():
if
k
in
(
'PARENTS'
,
'RESPONSE'
):
continue
...
...
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