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
c244e98a
Commit
c244e98a
authored
Jul 12, 2011
by
Nikolay Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace has_key with in operator
parent
05f73bda
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
89 additions
and
91 deletions
+89
-91
src/App/ApplicationManager.py
src/App/ApplicationManager.py
+1
-1
src/App/ProductContext.py
src/App/ProductContext.py
+2
-2
src/App/ProductRegistry.py
src/App/ProductRegistry.py
+2
-2
src/App/special_dtml.py
src/App/special_dtml.py
+1
-1
src/OFS/Image.py
src/OFS/Image.py
+1
-1
src/OFS/ObjectManager.py
src/OFS/ObjectManager.py
+2
-3
src/OFS/PropertyManager.py
src/OFS/PropertyManager.py
+2
-2
src/OFS/PropertySheets.py
src/OFS/PropertySheets.py
+4
-4
src/Products/Five/browser/decode.py
src/Products/Five/browser/decode.py
+2
-2
src/Products/PageTemplates/PageTemplateFile.py
src/Products/PageTemplates/PageTemplateFile.py
+1
-1
src/Products/PageTemplates/ZopePageTemplate.py
src/Products/PageTemplates/ZopePageTemplate.py
+1
-1
src/Products/SiteAccess/VirtualHostMonster.py
src/Products/SiteAccess/VirtualHostMonster.py
+1
-1
src/Shared/DC/Scripts/Bindings.py
src/Shared/DC/Scripts/Bindings.py
+5
-5
src/ZPublisher/BaseRequest.py
src/ZPublisher/BaseRequest.py
+3
-3
src/ZPublisher/BaseResponse.py
src/ZPublisher/BaseResponse.py
+1
-1
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+50
-50
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+6
-6
src/ZPublisher/Publish.py
src/ZPublisher/Publish.py
+1
-1
src/ZTUtils/Zope.py
src/ZTUtils/Zope.py
+3
-4
No files found.
src/App/ApplicationManager.py
View file @
c244e98a
...
@@ -353,7 +353,7 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -353,7 +353,7 @@ class ApplicationManager(Folder,CacheManager):
return
'%.1fM'
%
(
s
/
1048576.0
)
return
'%.1fM'
%
(
s
/
1048576.0
)
return
'%.1fK'
%
(
s
/
1024.0
)
return
'%.1fK'
%
(
s
/
1024.0
)
if
os
.
environ
.
has_key
(
'ZMANAGED'
)
:
if
'ZMANAGED'
in
os
.
environ
:
manage_restartable
=
1
manage_restartable
=
1
@
requestmethod
(
'POST'
)
@
requestmethod
(
'POST'
)
def
manage_restart
(
self
,
URL1
,
REQUEST
=
None
):
def
manage_restart
(
self
,
URL1
,
REQUEST
=
None
):
...
...
src/App/ProductContext.py
View file @
c244e98a
...
@@ -151,7 +151,7 @@ class ProductContext:
...
@@ -151,7 +151,7 @@ class ProductContext:
else
:
else
:
name
=
method
.
__name__
name
=
method
.
__name__
aliased
=
0
aliased
=
0
if
n
ot
OM
.
__dict__
.
has_key
(
name
)
:
if
n
ame
not
in
OM
.
__dict__
:
setattr
(
OM
,
name
,
method
)
setattr
(
OM
,
name
,
method
)
setattr
(
OM
,
name
+
'__roles__'
,
pr
)
setattr
(
OM
,
name
+
'__roles__'
,
pr
)
if
aliased
:
if
aliased
:
...
@@ -213,7 +213,7 @@ class ProductContext:
...
@@ -213,7 +213,7 @@ class ProductContext:
name
,
method
=
method
name
,
method
=
method
else
:
else
:
name
=
os
.
path
.
split
(
method
.
__name__
)[
-
1
]
name
=
os
.
path
.
split
(
method
.
__name__
)[
-
1
]
if
n
ot
productObject
.
__dict__
.
has_key
(
name
)
:
if
n
ame
not
in
productObject
.
__dict__
:
m
[
name
]
=
method
m
[
name
]
=
method
m
[
name
+
'__roles__'
]
=
pr
m
[
name
+
'__roles__'
]
=
pr
...
...
src/App/ProductRegistry.py
View file @
c244e98a
...
@@ -32,7 +32,7 @@ class ProductRegistryMixin:
...
@@ -32,7 +32,7 @@ class ProductRegistryMixin:
r
=
[]
r
=
[]
pid
=
product
.
id
pid
=
product
.
id
for
mt
in
self
.
_getProductRegistryMetaTypes
():
for
mt
in
self
.
_getProductRegistryMetaTypes
():
if
mt
.
has_key
(
'product'
)
:
if
'product'
in
mt
:
if
mt
[
'product'
]
==
pid
and
(
if
mt
[
'product'
]
==
pid
and
(
meta_type
is
None
or
meta_type
==
mt
[
'name'
]):
meta_type
is
None
or
meta_type
==
mt
[
'name'
]):
continue
continue
...
@@ -52,7 +52,7 @@ class ProductRegistryMixin:
...
@@ -52,7 +52,7 @@ class ProductRegistryMixin:
for
mt
in
meta_types
:
for
mt
in
meta_types
:
if
mt
[
'name'
]
==
meta_type
:
if
mt
[
'name'
]
==
meta_type
:
if
not
mt
.
has_key
(
'product'
)
:
mt
[
'product'
]
=
pid
if
'product'
not
in
mt
:
mt
[
'product'
]
=
pid
if
mt
[
'product'
]
!=
pid
:
if
mt
[
'product'
]
!=
pid
:
raise
ValueError
,
(
raise
ValueError
,
(
'The type <em>%s</em> is already defined.'
%
meta_type
)
'The type <em>%s</em> is already defined.'
%
meta_type
)
...
...
src/App/special_dtml.py
View file @
c244e98a
...
@@ -44,7 +44,7 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
...
@@ -44,7 +44,7 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
elif
type
(
_prefix
)
is
not
type
(
''
):
elif
type
(
_prefix
)
is
not
type
(
''
):
_prefix
=
Common
.
package_home
(
_prefix
)
_prefix
=
Common
.
package_home
(
_prefix
)
args
=
(
self
,
os
.
path
.
join
(
_prefix
,
name
+
'.dtml'
))
args
=
(
self
,
os
.
path
.
join
(
_prefix
,
name
+
'.dtml'
))
if
not
kw
.
has_key
(
'__name__'
)
:
if
'__name__'
not
in
kw
:
kw
[
'__name__'
]
=
os
.
path
.
split
(
name
)[
-
1
]
kw
[
'__name__'
]
=
os
.
path
.
split
(
name
)[
-
1
]
apply
(
ClassicHTMLFile
.
inheritedAttribute
(
'__init__'
),
args
,
kw
)
apply
(
ClassicHTMLFile
.
inheritedAttribute
(
'__init__'
),
args
,
kw
)
...
...
src/OFS/Image.py
View file @
c244e98a
...
@@ -504,7 +504,7 @@ class File(Persistent, Implicit, PropertyManager,
...
@@ -504,7 +504,7 @@ class File(Persistent, Implicit, PropertyManager,
def
_get_content_type
(
self
,
file
,
body
,
id
,
content_type
=
None
):
def
_get_content_type
(
self
,
file
,
body
,
id
,
content_type
=
None
):
headers
=
getattr
(
file
,
'headers'
,
None
)
headers
=
getattr
(
file
,
'headers'
,
None
)
if
headers
and
headers
.
has_key
(
'content-type'
)
:
if
headers
and
'content-type'
in
headers
:
content_type
=
headers
[
'content-type'
]
content_type
=
headers
[
'content-type'
]
else
:
else
:
if
not
isinstance
(
body
,
str
):
body
=
body
.
data
if
not
isinstance
(
body
,
str
):
body
=
body
.
data
...
...
src/OFS/ObjectManager.py
View file @
c244e98a
...
@@ -273,7 +273,7 @@ class ObjectManager(CopyContainer,
...
@@ -273,7 +273,7 @@ class ObjectManager(CopyContainer,
else
:
else
:
all
=
self
.
all_meta_types
all
=
self
.
all_meta_types
for
meta_type
in
all
:
for
meta_type
in
all
:
if
meta_type
.
has_key
(
'permission'
)
:
if
'permission'
in
meta_type
:
if
sm
.
checkPermission
(
meta_type
[
'permission'
],
self
):
if
sm
.
checkPermission
(
meta_type
[
'permission'
],
self
):
meta_types
.
append
(
meta_type
)
meta_types
.
append
(
meta_type
)
else
:
else
:
...
@@ -476,7 +476,6 @@ class ObjectManager(CopyContainer,
...
@@ -476,7 +476,6 @@ class ObjectManager(CopyContainer,
seen
=
{}
seen
=
{}
vals
=
[]
vals
=
[]
relativePhysicalPath
=
()
relativePhysicalPath
=
()
have
=
seen
.
has_key
x
=
0
x
=
0
while
x
<
100
:
while
x
<
100
:
if
not
hasattr
(
obj
,
'_getOb'
):
break
if
not
hasattr
(
obj
,
'_getOb'
):
break
...
@@ -486,7 +485,7 @@ class ObjectManager(CopyContainer,
...
@@ -486,7 +485,7 @@ class ObjectManager(CopyContainer,
try
:
try
:
id
=
i
[
'id'
]
id
=
i
[
'id'
]
physicalPath
=
relativePhysicalPath
+
(
id
,)
physicalPath
=
relativePhysicalPath
+
(
id
,)
if
(
not
have
(
physicalPath
)
)
and
(
i
[
'meta_type'
]
in
t
):
if
(
physicalPath
not
in
seen
)
and
(
i
[
'meta_type'
]
in
t
):
vals
.
append
(
get
(
id
))
vals
.
append
(
get
(
id
))
seen
[
physicalPath
]
=
1
seen
[
physicalPath
]
=
1
except
:
pass
except
:
pass
...
...
src/OFS/PropertyManager.py
View file @
c244e98a
...
@@ -204,7 +204,7 @@ class PropertyManager(Base, ElementWithAttributes):
...
@@ -204,7 +204,7 @@ class PropertyManager(Base, ElementWithAttributes):
raise
BadRequest
,
'The property %s does not exist'
%
escape
(
id
)
raise
BadRequest
,
'The property %s does not exist'
%
escape
(
id
)
if
type
(
value
)
==
type
(
''
):
if
type
(
value
)
==
type
(
''
):
proptype
=
self
.
getPropertyType
(
id
)
or
'string'
proptype
=
self
.
getPropertyType
(
id
)
or
'string'
if
type_converters
.
has_key
(
proptype
)
:
if
proptype
in
type_converters
:
value
=
type_converters
[
proptype
](
value
)
value
=
type_converters
[
proptype
](
value
)
self
.
_setPropValue
(
id
,
value
)
self
.
_setPropValue
(
id
,
value
)
...
@@ -281,7 +281,7 @@ class PropertyManager(Base, ElementWithAttributes):
...
@@ -281,7 +281,7 @@ class PropertyManager(Base, ElementWithAttributes):
Sets a new property with the given id, type, and value.
Sets a new property with the given id, type, and value.
"""
"""
if
type
_converters
.
has_key
(
type
)
:
if
type
in
type_converters
:
value
=
type_converters
[
type
](
value
)
value
=
type_converters
[
type
](
value
)
self
.
_setProperty
(
id
.
strip
(),
value
,
type
)
self
.
_setProperty
(
id
.
strip
(),
value
,
type
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
...
...
src/OFS/PropertySheets.py
View file @
c244e98a
...
@@ -199,7 +199,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -199,7 +199,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
pself
=
self
.
p_self
()
pself
=
self
.
p_self
()
self
=
self
.
v_self
()
self
=
self
.
v_self
()
if
hasattr
(
aq_base
(
self
),
id
):
if
hasattr
(
aq_base
(
self
),
id
):
if
not
(
id
==
'title'
and
not
self
.
__dict__
.
has_key
(
id
)
):
if
not
(
id
==
'title'
and
not
id
in
self
.
__dict__
):
raise
BadRequest
,
(
raise
BadRequest
,
(
'Invalid property id, <em>%s</em>. It is in use.'
%
'Invalid property id, <em>%s</em>. It is in use.'
%
escape
(
id
))
escape
(
id
))
...
@@ -233,7 +233,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -233,7 +233,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
raise
BadRequest
,
'%s cannot be changed.'
%
escape
(
id
)
raise
BadRequest
,
'%s cannot be changed.'
%
escape
(
id
)
if
type
(
value
)
==
type
(
''
):
if
type
(
value
)
==
type
(
''
):
proptype
=
propinfo
.
get
(
'type'
,
'string'
)
proptype
=
propinfo
.
get
(
'type'
,
'string'
)
if
type_converters
.
has_key
(
proptype
)
:
if
proptype
in
type_converters
:
value
=
type_converters
[
proptype
](
value
)
value
=
type_converters
[
proptype
](
value
)
if
meta
is
not
None
:
if
meta
is
not
None
:
props
=
[]
props
=
[]
...
@@ -361,7 +361,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -361,7 +361,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
# property name and value for the requested property.
# property name and value for the requested property.
xml_id
=
self
.
xml_namespace
()
xml_id
=
self
.
xml_namespace
()
propdict
=
self
.
_propdict
()
propdict
=
self
.
_propdict
()
if
n
ot
propdict
.
has_key
(
name
)
:
if
n
ame
not
in
propdict
:
if
xml_id
:
if
xml_id
:
prop
=
'<n:%s xmlns:n="%s"/>
\
n
'
%
(
name
,
xml_id
)
prop
=
'<n:%s xmlns:n="%s"/>
\
n
'
%
(
name
,
xml_id
)
else
:
else
:
...
@@ -419,7 +419,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -419,7 +419,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
def
manage_addProperty
(
self
,
id
,
value
,
type
,
REQUEST
=
None
):
def
manage_addProperty
(
self
,
id
,
value
,
type
,
REQUEST
=
None
):
"""Add a new property via the web. Sets a new property with
"""Add a new property via the web. Sets a new property with
the given id, type, and value."""
the given id, type, and value."""
if
type
_converters
.
has_key
(
type
)
:
if
type
in
type_converters
:
value
=
type_converters
[
type
](
value
)
value
=
type_converters
[
type
](
value
)
self
.
_setProperty
(
id
,
value
,
type
)
self
.
_setProperty
(
id
,
value
,
type
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
...
...
src/Products/Five/browser/decode.py
View file @
c244e98a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
encoding.
encoding.
"""
"""
from
zope.publisher.browser
import
isCGI_NAME
from
ZPublisher.HTTPRequest
import
isCGI_NAMEs
from
zope.i18n.interfaces
import
IUserPreferredCharsets
from
zope.i18n.interfaces
import
IUserPreferredCharsets
# taken and adapted from zope.publisher.browser.BrowserRequest
# taken and adapted from zope.publisher.browser.BrowserRequest
...
@@ -62,7 +62,7 @@ def processInputs(request, charsets=None):
...
@@ -62,7 +62,7 @@ def processInputs(request, charsets=None):
charsets
=
envadapter
.
getPreferredCharsets
()
or
[
'utf-8'
]
charsets
=
envadapter
.
getPreferredCharsets
()
or
[
'utf-8'
]
for
name
,
value
in
request
.
form
.
items
():
for
name
,
value
in
request
.
form
.
items
():
if
not
(
isCGI_NAME
(
name
)
or
name
.
startswith
(
'HTTP_'
)):
if
not
(
name
in
isCGI_NAMEs
or
name
.
startswith
(
'HTTP_'
)):
request
.
form
[
name
]
=
processInputValue
(
value
,
charsets
)
request
.
form
[
name
]
=
processInputValue
(
value
,
charsets
)
def
setPageEncoding
(
request
):
def
setPageEncoding
(
request
):
...
...
src/Products/PageTemplates/PageTemplateFile.py
View file @
c244e98a
...
@@ -109,7 +109,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
...
@@ -109,7 +109,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
def
_exec
(
self
,
bound_names
,
args
,
kw
):
def
_exec
(
self
,
bound_names
,
args
,
kw
):
"""Call a Page Template"""
"""Call a Page Template"""
self
.
_cook_check
()
self
.
_cook_check
()
if
not
kw
.
has_key
(
'args'
)
:
if
'args'
not
in
kw
:
kw
[
'args'
]
=
args
kw
[
'args'
]
=
args
bound_names
[
'options'
]
=
kw
bound_names
[
'options'
]
=
kw
...
...
src/Products/PageTemplates/ZopePageTemplate.py
View file @
c244e98a
...
@@ -303,7 +303,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
...
@@ -303,7 +303,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def
_exec
(
self
,
bound_names
,
args
,
kw
):
def
_exec
(
self
,
bound_names
,
args
,
kw
):
"""Call a Page Template"""
"""Call a Page Template"""
if
not
kw
.
has_key
(
'args'
)
:
if
'args'
not
in
kw
:
kw
[
'args'
]
=
args
kw
[
'args'
]
=
args
bound_names
[
'options'
]
=
kw
bound_names
[
'options'
]
=
kw
...
...
src/Products/SiteAccess/VirtualHostMonster.py
View file @
c244e98a
...
@@ -97,7 +97,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
...
@@ -97,7 +97,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
else
:
else
:
host_map
=
fixed_map
host_map
=
fixed_map
hostname
,
port
=
(
host
.
split
(
':'
,
1
)
+
[
None
])[:
2
]
hostname
,
port
=
(
host
.
split
(
':'
,
1
)
+
[
None
])[:
2
]
if
not
host_map
.
has_key
(
hostname
)
:
if
hostname
not
in
host_map
:
host_map
[
hostname
]
=
{}
host_map
[
hostname
]
=
{}
host_map
[
hostname
][
port
]
=
pp
host_map
[
hostname
][
port
]
=
pp
except
'LineError'
,
msg
:
except
'LineError'
,
msg
:
...
...
src/Shared/DC/Scripts/Bindings.py
View file @
c244e98a
...
@@ -55,7 +55,7 @@ class NameAssignments:
...
@@ -55,7 +55,7 @@ class NameAssignments:
asgns
=
{}
asgns
=
{}
_isLegalName
=
self
.
_isLegalName
_isLegalName
=
self
.
_isLegalName
for
name
,
expr
in
self
.
_exprs
:
for
name
,
expr
in
self
.
_exprs
:
if
mapping
.
has_key
(
name
)
:
if
name
in
mapping
:
assigned_name
=
string
.
strip
(
mapping
[
name
])
assigned_name
=
string
.
strip
(
mapping
[
name
])
if
not
assigned_name
:
if
not
assigned_name
:
continue
continue
...
@@ -71,7 +71,7 @@ class NameAssignments:
...
@@ -71,7 +71,7 @@ class NameAssignments:
return
0
return
0
def
isNameAssigned
(
self
,
name
):
def
isNameAssigned
(
self
,
name
):
return
self
.
_asgns
.
has_key
(
name
)
return
name
in
self
.
_asgns
def
getAssignedName
(
self
,
name
,
default
=
_marker
):
def
getAssignedName
(
self
,
name
,
default
=
_marker
):
val
=
self
.
_asgns
.
get
(
name
,
default
)
val
=
self
.
_asgns
.
get
(
name
,
default
)
...
@@ -89,7 +89,7 @@ class NameAssignments:
...
@@ -89,7 +89,7 @@ class NameAssignments:
rval
=
[]
rval
=
[]
asgns
=
self
.
_asgns
asgns
=
self
.
_asgns
for
name
,
expr
in
self
.
_exprs
:
for
name
,
expr
in
self
.
_exprs
:
if
asgns
.
has_key
(
name
)
:
if
name
in
asgns
:
assigned_name
=
asgns
[
name
]
assigned_name
=
asgns
[
name
]
rval
.
append
(
assigned_name
)
rval
.
append
(
assigned_name
)
return
rval
return
rval
...
@@ -114,7 +114,7 @@ class NameAssignments:
...
@@ -114,7 +114,7 @@ class NameAssignments:
assigned_names
=
[]
assigned_names
=
[]
asgns
=
self
.
_asgns
asgns
=
self
.
_asgns
for
name
,
expr
in
self
.
_exprs
:
for
name
,
expr
in
self
.
_exprs
:
if
asgns
.
has_key
(
name
)
:
if
name
in
asgns
:
assigned_name
=
asgns
[
name
]
assigned_name
=
asgns
[
name
]
assigned_names
.
append
(
assigned_name
)
assigned_names
.
append
(
assigned_name
)
exprtext
.
append
(
'"%s":%s,'
%
(
assigned_name
,
expr
))
exprtext
.
append
(
'"%s":%s,'
%
(
assigned_name
,
expr
))
...
@@ -133,7 +133,7 @@ class NameAssignments:
...
@@ -133,7 +133,7 @@ class NameAssignments:
passedLastBoundArg
=
1
passedLastBoundArg
=
1
for
name
,
expr
in
self
.
_exprs
:
for
name
,
expr
in
self
.
_exprs
:
# Provide a value for the available exprs.
# Provide a value for the available exprs.
if
asgns
.
has_key
(
name
)
:
if
name
in
asgns
:
assigned_name
=
asgns
[
name
]
assigned_name
=
asgns
[
name
]
if
assigned_name
==
argName
:
if
assigned_name
==
argName
:
# The value for this argument will be filled in.
# The value for this argument will be filled in.
...
...
src/ZPublisher/BaseRequest.py
View file @
c244e98a
...
@@ -669,7 +669,7 @@ def old_validation(groups, request, auth,
...
@@ -669,7 +669,7 @@ def old_validation(groups, request, auth,
if
auth
:
name
,
password
=
auth
if
auth
:
name
,
password
=
auth
elif
roles
is
None
:
return
''
elif
roles
is
None
:
return
''
else
:
return
None
else
:
return
None
elif
request
.
environ
.
has_key
(
'REMOTE_USER'
)
:
elif
'REMOTE_USER'
in
request
.
environ
:
name
=
request
.
environ
[
'REMOTE_USER'
]
name
=
request
.
environ
[
'REMOTE_USER'
]
password
=
None
password
=
None
else
:
else
:
...
@@ -693,11 +693,11 @@ def old_validation(groups, request, auth,
...
@@ -693,11 +693,11 @@ def old_validation(groups, request, auth,
if
roles
is
UNSPECIFIED_ROLES
:
roles
=
keys
()
if
roles
is
UNSPECIFIED_ROLES
:
roles
=
keys
()
g
=
[]
g
=
[]
for
role
in
roles
:
for
role
in
roles
:
if
groups
.
has_key
(
role
)
:
g
.
append
(
groups
[
role
])
if
role
in
groups
:
g
.
append
(
groups
[
role
])
groups
=
g
groups
=
g
for
d
in
groups
:
for
d
in
groups
:
if
d
.
has_key
(
name
)
and
(
d
[
name
]
==
password
or
password
is
None
):
if
name
in
d
and
(
d
[
name
]
==
password
or
password
is
None
):
return
name
return
name
if
keys
is
None
:
if
keys
is
None
:
...
...
src/ZPublisher/BaseResponse.py
View file @
c244e98a
...
@@ -69,7 +69,7 @@ class BaseResponse:
...
@@ -69,7 +69,7 @@ class BaseResponse:
cookie in the Response object.
cookie in the Response object.
'''
'''
cookies
=
self
.
cookies
cookies
=
self
.
cookies
if
cookies
.
has_key
(
name
)
:
if
name
in
cookies
:
cookie
=
cookies
[
name
]
cookie
=
cookies
[
name
]
else
:
else
:
cookie
=
cookies
[
name
]
=
{}
cookie
=
cookies
[
name
]
=
{}
...
...
src/ZPublisher/HTTPRequest.py
View file @
c244e98a
...
@@ -59,7 +59,7 @@ base64 = None
...
@@ -59,7 +59,7 @@ base64 = None
# This may get overwritten during configuration
# This may get overwritten during configuration
default_encoding
=
'iso-8859-15'
default_encoding
=
'iso-8859-15'
isCGI_NAME
=
{
isCGI_NAME
s
=
{
'SERVER_SOFTWARE'
:
1
,
'SERVER_SOFTWARE'
:
1
,
'SERVER_NAME'
:
1
,
'SERVER_NAME'
:
1
,
'GATEWAY_INTERFACE'
:
1
,
'GATEWAY_INTERFACE'
:
1
,
...
@@ -78,9 +78,11 @@ isCGI_NAME = {
...
@@ -78,9 +78,11 @@ isCGI_NAME = {
'CONTENT_TYPE'
:
1
,
'CONTENT_TYPE'
:
1
,
'CONTENT_LENGTH'
:
1
,
'CONTENT_LENGTH'
:
1
,
'SERVER_URL'
:
1
,
'SERVER_URL'
:
1
,
}
.
has_key
}
hide_key
=
{
'HTTP_AUTHORIZATION'
:
1
,
'HTTP_CGI_AUTHORIZATION'
:
1
}.
has_key
isCGI_NAME
=
isCGI_NAMEs
.
has_key
hide_key
=
{
'HTTP_AUTHORIZATION'
:
1
,
'HTTP_CGI_AUTHORIZATION'
:
1
}
default_port
=
{
'http'
:
'80'
,
'https'
:
'443'
}
default_port
=
{
'http'
:
'80'
,
'https'
:
'443'
}
...
@@ -321,14 +323,13 @@ class HTTPRequest(BaseRequest):
...
@@ -321,14 +323,13 @@ class HTTPRequest(BaseRequest):
if
not
clean
:
if
not
clean
:
environ
=
sane_environment
(
environ
)
environ
=
sane_environment
(
environ
)
if
environ
.
has_key
(
'HTTP_AUTHORIZATION'
)
:
if
'HTTP_AUTHORIZATION'
in
environ
:
self
.
_auth
=
environ
[
'HTTP_AUTHORIZATION'
]
self
.
_auth
=
environ
[
'HTTP_AUTHORIZATION'
]
response
.
_auth
=
1
response
.
_auth
=
1
del
environ
[
'HTTP_AUTHORIZATION'
]
del
environ
[
'HTTP_AUTHORIZATION'
]
self
.
stdin
=
stdin
self
.
stdin
=
stdin
self
.
environ
=
environ
self
.
environ
=
environ
have_env
=
environ
.
has_key
get_env
=
environ
.
get
get_env
=
environ
.
get
self
.
response
=
response
self
.
response
=
response
other
=
self
.
other
=
{
'RESPONSE'
:
response
}
other
=
self
.
other
=
{
'RESPONSE'
:
response
}
...
@@ -341,9 +342,9 @@ class HTTPRequest(BaseRequest):
...
@@ -341,9 +342,9 @@ class HTTPRequest(BaseRequest):
# We don't set up the locale initially but just on first access
# We don't set up the locale initially but just on first access
self
.
_locale
=
_marker
self
.
_locale
=
_marker
if
environ
.
has_key
(
'REMOTE_ADDR'
)
:
if
'REMOTE_ADDR'
in
environ
:
self
.
_client_addr
=
environ
[
'REMOTE_ADDR'
]
self
.
_client_addr
=
environ
[
'REMOTE_ADDR'
]
if
(
environ
.
has_key
(
'HTTP_X_FORWARDED_FOR'
)
and
if
(
'HTTP_X_FORWARDED_FOR'
in
environ
and
self
.
_client_addr
in
trusted_proxies
):
self
.
_client_addr
in
trusted_proxies
):
# REMOTE_ADDR is one of our trusted local proxies.
# REMOTE_ADDR is one of our trusted local proxies.
# Not really very remote at all. The proxy can tell us the
# Not really very remote at all. The proxy can tell us the
...
@@ -382,16 +383,16 @@ class HTTPRequest(BaseRequest):
...
@@ -382,16 +383,16 @@ class HTTPRequest(BaseRequest):
if
server_url
is
not
None
:
if
server_url
is
not
None
:
other
[
'SERVER_URL'
]
=
server_url
=
server_url
.
strip
()
other
[
'SERVER_URL'
]
=
server_url
=
server_url
.
strip
()
else
:
else
:
if
have_env
(
'HTTPS'
)
and
(
if
'HTTPS'
in
environ
and
(
environ
[
'HTTPS'
]
==
"on"
or
environ
[
'HTTPS'
]
==
"ON"
):
environ
[
'HTTPS'
]
==
"on"
or
environ
[
'HTTPS'
]
==
"ON"
):
protocol
=
'https'
protocol
=
'https'
elif
(
have_env
(
'SERVER_PORT_SECURE'
)
and
elif
(
'SERVER_PORT_SECURE'
in
environ
and
environ
[
'SERVER_PORT_SECURE'
]
==
"1"
):
environ
[
'SERVER_PORT_SECURE'
]
==
"1"
):
protocol
=
'https'
protocol
=
'https'
else
:
else
:
protocol
=
'http'
protocol
=
'http'
if
have_env
(
'HTTP_HOST'
)
:
if
'HTTP_HOST'
in
environ
:
host
=
environ
[
'HTTP_HOST'
].
strip
()
host
=
environ
[
'HTTP_HOST'
].
strip
()
hostname
,
port
=
splitport
(
host
)
hostname
,
port
=
splitport
(
host
)
...
@@ -401,7 +402,7 @@ class HTTPRequest(BaseRequest):
...
@@ -401,7 +402,7 @@ class HTTPRequest(BaseRequest):
# the commented code here in case we care enough to come
# the commented code here in case we care enough to come
# back and do anything with it later.
# back and do anything with it later.
#
#
# if port is None and
environ.has_key('SERVER_PORT')
:
# if port is None and
'SERVER_PORT' in environ
:
# s_port = environ['SERVER_PORT']
# s_port = environ['SERVER_PORT']
# if s_port not in ('80', '443'):
# if s_port not in ('80', '443'):
# port = s_port
# port = s_port
...
@@ -486,17 +487,17 @@ class HTTPRequest(BaseRequest):
...
@@ -486,17 +487,17 @@ class HTTPRequest(BaseRequest):
# If 'QUERY_STRING' is not present in environ
# If 'QUERY_STRING' is not present in environ
# FieldStorage will try to get it from sys.argv[1]
# FieldStorage will try to get it from sys.argv[1]
# which is not what we need.
# which is not what we need.
if
not
environ
.
has_key
(
'QUERY_STRING'
)
:
if
'QUERY_STRING'
not
in
environ
:
environ
[
'QUERY_STRING'
]
=
''
environ
[
'QUERY_STRING'
]
=
''
meth
=
None
meth
=
None
fs
=
ZopeFieldStorage
(
fp
=
fp
,
environ
=
environ
,
keep_blank_values
=
1
)
fs
=
ZopeFieldStorage
(
fp
=
fp
,
environ
=
environ
,
keep_blank_values
=
1
)
if
not
hasattr
(
fs
,
'list'
)
or
fs
.
list
is
None
:
if
not
hasattr
(
fs
,
'list'
)
or
fs
.
list
is
None
:
if
environ
.
has_key
(
'HTTP_SOAPACTION'
)
:
if
'HTTP_SOAPACTION'
in
environ
:
# Stash XML request for interpretation by a SOAP-aware view
# Stash XML request for interpretation by a SOAP-aware view
other
[
'SOAPXML'
]
=
fs
.
value
other
[
'SOAPXML'
]
=
fs
.
value
# Hm, maybe it's an XML-RPC
# Hm, maybe it's an XML-RPC
elif
(
fs
.
headers
.
has_key
(
'content-type'
)
and
elif
(
'content-type'
in
fs
.
headers
and
'text/xml'
in
fs
.
headers
[
'content-type'
]
and
'text/xml'
in
fs
.
headers
[
'content-type'
]
and
method
==
'POST'
):
method
==
'POST'
):
# Ye haaa, XML-RPC!
# Ye haaa, XML-RPC!
...
@@ -513,7 +514,7 @@ class HTTPRequest(BaseRequest):
...
@@ -513,7 +514,7 @@ class HTTPRequest(BaseRequest):
fslist
=
fs
.
list
fslist
=
fs
.
list
tuple_items
=
{}
tuple_items
=
{}
lt
=
type
([])
lt
=
type
([])
CGI_name
=
isCGI_NAME
CGI_name
=
isCGI_NAME
s
defaults
=
{}
defaults
=
{}
tainteddefaults
=
{}
tainteddefaults
=
{}
converter
=
None
converter
=
None
...
@@ -605,7 +606,7 @@ class HTTPRequest(BaseRequest):
...
@@ -605,7 +606,7 @@ class HTTPRequest(BaseRequest):
l
=
-
1
l
=
-
1
# Filter out special names from form:
# Filter out special names from form:
if
CGI_name
(
key
)
or
key
[:
5
]
==
'HTTP_'
:
if
key
in
CGI_name
or
key
[:
5
]
==
'HTTP_'
:
continue
continue
# If the key is tainted, mark it so as well.
# If the key is tainted, mark it so as well.
...
@@ -670,13 +671,13 @@ class HTTPRequest(BaseRequest):
...
@@ -670,13 +671,13 @@ class HTTPRequest(BaseRequest):
except
:
except
:
if
(
not
item
and
not
(
flags
&
DEFAULT
)
and
if
(
not
item
and
not
(
flags
&
DEFAULT
)
and
defaults
.
has_key
(
key
)
):
key
in
defaults
):
item
=
defaults
[
key
]
item
=
defaults
[
key
]
if
flags
&
RECORD
:
if
flags
&
RECORD
:
item
=
getattr
(
item
,
attr
)
item
=
getattr
(
item
,
attr
)
if
flags
&
RECORDS
:
if
flags
&
RECORDS
:
item
=
getattr
(
item
[
-
1
],
attr
)
item
=
getattr
(
item
[
-
1
],
attr
)
if
tainted
defaults
.
has_key
(
tainted_key
)
:
if
tainted
_key
in
tainteddefaults
:
tainted
=
tainteddefaults
[
tainted_key
]
tainted
=
tainteddefaults
[
tainted_key
]
if
flags
&
RECORD
:
if
flags
&
RECORD
:
tainted
=
getattr
(
tainted
,
attr
)
tainted
=
getattr
(
tainted
,
attr
)
...
@@ -703,7 +704,7 @@ class HTTPRequest(BaseRequest):
...
@@ -703,7 +704,7 @@ class HTTPRequest(BaseRequest):
tainted_mapping
=
taintedform
tainted_mapping
=
taintedform
#Insert in dictionary
#Insert in dictionary
if
mapping_object
.
has_key
(
key
)
:
if
key
in
mapping_object
:
if
flags
&
RECORDS
:
if
flags
&
RECORDS
:
#Get the list and the last record
#Get the list and the last record
#in the list. reclist is mutable.
#in the list. reclist is mutable.
...
@@ -712,7 +713,7 @@ class HTTPRequest(BaseRequest):
...
@@ -712,7 +713,7 @@ class HTTPRequest(BaseRequest):
if
tainted
:
if
tainted
:
# Store a tainted copy as well
# Store a tainted copy as well
if
not
tainted_mapping
.
has_key
(
tainted_key
)
:
if
tainted_key
not
in
tainted_mapping
:
tainted_mapping
[
tainted_key
]
=
deepcopy
(
tainted_mapping
[
tainted_key
]
=
deepcopy
(
reclist
)
reclist
)
treclist
=
tainted_mapping
[
tainted_key
]
treclist
=
tainted_mapping
[
tainted_key
]
...
@@ -731,7 +732,7 @@ class HTTPRequest(BaseRequest):
...
@@ -731,7 +732,7 @@ class HTTPRequest(BaseRequest):
setattr
(
newrec
,
attr
,
tainted
)
setattr
(
newrec
,
attr
,
tainted
)
treclist
.
append
(
newrec
)
treclist
.
append
(
newrec
)
elif
tainted_
mapping
.
has_key
(
tainted_key
)
:
elif
tainted_
key
in
tainted_mapping
:
# If we already put a tainted value into this
# If we already put a tainted value into this
# recordset, we need to make sure the whole
# recordset, we need to make sure the whole
# recordset is built.
# recordset is built.
...
@@ -791,7 +792,7 @@ class HTTPRequest(BaseRequest):
...
@@ -791,7 +792,7 @@ class HTTPRequest(BaseRequest):
# Store a tainted copy as well if necessary
# Store a tainted copy as well if necessary
if
tainted
:
if
tainted
:
if
not
tainted_mapping
.
has_key
(
tainted_key
)
:
if
tainted_key
not
in
tainted_mapping
:
tainted_mapping
[
tainted_key
]
=
deepcopy
(
tainted_mapping
[
tainted_key
]
=
deepcopy
(
mapping_object
[
key
])
mapping_object
[
key
])
b
=
tainted_mapping
[
tainted_key
]
b
=
tainted_mapping
[
tainted_key
]
...
@@ -802,7 +803,7 @@ class HTTPRequest(BaseRequest):
...
@@ -802,7 +803,7 @@ class HTTPRequest(BaseRequest):
else
:
else
:
setattr
(
b
,
attr
,
tainted
)
setattr
(
b
,
attr
,
tainted
)
elif
tainted_
mapping
.
has_key
(
tainted_key
)
:
elif
tainted_
key
in
tainted_mapping
:
# If we already put a tainted value into this
# If we already put a tainted value into this
# record, we need to make sure the whole record
# record, we need to make sure the whole record
# is built.
# is built.
...
@@ -820,7 +821,7 @@ class HTTPRequest(BaseRequest):
...
@@ -820,7 +821,7 @@ class HTTPRequest(BaseRequest):
if
tainted
:
if
tainted
:
# Store a tainted version if necessary
# Store a tainted version if necessary
if
not
tainted_mapping
.
has_key
(
tainted_key
)
:
if
tainted_key
not
in
tainted_mapping
:
copied
=
deepcopy
(
found
)
copied
=
deepcopy
(
found
)
if
isinstance
(
copied
,
lt
):
if
isinstance
(
copied
,
lt
):
tainted_mapping
[
tainted_key
]
=
copied
tainted_mapping
[
tainted_key
]
=
copied
...
@@ -828,7 +829,7 @@ class HTTPRequest(BaseRequest):
...
@@ -828,7 +829,7 @@ class HTTPRequest(BaseRequest):
tainted_mapping
[
tainted_key
]
=
[
copied
]
tainted_mapping
[
tainted_key
]
=
[
copied
]
tainted_mapping
[
tainted_key
].
append
(
tainted
)
tainted_mapping
[
tainted_key
].
append
(
tainted
)
elif
tainted_
mapping
.
has_key
(
tainted_key
)
:
elif
tainted_
key
in
tainted_mapping
:
# We may already have encountered a tainted
# We may already have encountered a tainted
# value for this key, and the tainted_mapping
# value for this key, and the tainted_mapping
# needs to hold all the values.
# needs to hold all the values.
...
@@ -899,13 +900,13 @@ class HTTPRequest(BaseRequest):
...
@@ -899,13 +900,13 @@ class HTTPRequest(BaseRequest):
tainted
=
item
tainted
=
item
#Insert in dictionary
#Insert in dictionary
if
mapping_object
.
has_key
(
key
)
:
if
key
in
mapping_object
:
# it is not a record or list of records
# it is not a record or list of records
found
=
mapping_object
[
key
]
found
=
mapping_object
[
key
]
if
tainted
:
if
tainted
:
# Store a tainted version if necessary
# Store a tainted version if necessary
if
not
taintedform
.
has_key
(
tainted_key
)
:
if
tainted_key
not
in
taintedform
:
copied
=
deepcopy
(
found
)
copied
=
deepcopy
(
found
)
if
isinstance
(
copied
,
lt
):
if
isinstance
(
copied
,
lt
):
taintedform
[
tainted_key
]
=
copied
taintedform
[
tainted_key
]
=
copied
...
@@ -916,7 +917,7 @@ class HTTPRequest(BaseRequest):
...
@@ -916,7 +917,7 @@ class HTTPRequest(BaseRequest):
taintedform
[
tainted_key
]]
taintedform
[
tainted_key
]]
taintedform
[
tainted_key
].
append
(
tainted
)
taintedform
[
tainted_key
].
append
(
tainted
)
elif
tainted
form
.
has_key
(
tainted_key
)
:
elif
tainted
_key
in
taintedform
:
# We may already have encountered a tainted value
# We may already have encountered a tainted value
# for this key, and the taintedform needs to hold
# for this key, and the taintedform needs to hold
# all the values.
# all the values.
...
@@ -943,12 +944,12 @@ class HTTPRequest(BaseRequest):
...
@@ -943,12 +944,12 @@ class HTTPRequest(BaseRequest):
if
'<'
in
key
:
if
'<'
in
key
:
tainted_key
=
TaintedString
(
key
)
tainted_key
=
TaintedString
(
key
)
if
not
form
.
has_key
(
key
)
:
if
key
not
in
form
:
# if the form does not have the key,
# if the form does not have the key,
# set the default
# set the default
form
[
key
]
=
value
form
[
key
]
=
value
if
tainted
defaults
.
has_key
(
tainted_key
)
:
if
tainted
_key
in
tainteddefaults
:
taintedform
[
tainted_key
]
=
\
taintedform
[
tainted_key
]
=
\
tainteddefaults
[
tainted_key
]
tainteddefaults
[
tainted_key
]
else
:
else
:
...
@@ -960,13 +961,13 @@ class HTTPRequest(BaseRequest):
...
@@ -960,13 +961,13 @@ class HTTPRequest(BaseRequest):
r
=
form
[
key
]
r
=
form
[
key
]
# First deal with tainted defaults.
# First deal with tainted defaults.
if
tainted
form
.
has_key
(
tainted_key
)
:
if
tainted
_key
in
taintedform
:
tainted
=
taintedform
[
tainted_key
]
tainted
=
taintedform
[
tainted_key
]
for
k
,
v
in
tdefault
.
__dict__
.
items
():
for
k
,
v
in
tdefault
.
__dict__
.
items
():
if
not
hasattr
(
tainted
,
k
):
if
not
hasattr
(
tainted
,
k
):
setattr
(
tainted
,
k
,
v
)
setattr
(
tainted
,
k
,
v
)
elif
tainted
defaults
.
has_key
(
tainted_key
)
:
elif
tainted
_key
in
tainteddefaults
:
# Find out if any of the tainted default
# Find out if any of the tainted default
# attributes needs to be copied over.
# attributes needs to be copied over.
missesdefault
=
0
missesdefault
=
0
...
@@ -997,7 +998,7 @@ class HTTPRequest(BaseRequest):
...
@@ -997,7 +998,7 @@ class HTTPRequest(BaseRequest):
l
=
[
l
]
l
=
[
l
]
# First deal with tainted copies
# First deal with tainted copies
if
tainted
form
.
has_key
(
tainted_key
)
:
if
tainted
_key
in
taintedform
:
tainted
=
taintedform
[
tainted_key
]
tainted
=
taintedform
[
tainted_key
]
if
not
isinstance
(
tainted
,
lt
):
if
not
isinstance
(
tainted
,
lt
):
tainted
=
[
tainted
]
tainted
=
[
tainted
]
...
@@ -1012,7 +1013,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1012,7 +1013,7 @@ class HTTPRequest(BaseRequest):
tainted
.
append
(
defitem
)
tainted
.
append
(
defitem
)
taintedform
[
tainted_key
]
=
tainted
taintedform
[
tainted_key
]
=
tainted
elif
tainted
defaults
.
has_key
(
tainted_key
)
:
elif
tainted
_key
in
tainteddefaults
:
missesdefault
=
0
missesdefault
=
0
for
defitem
in
tdefault
:
for
defitem
in
tdefault
:
if
isinstance
(
defitem
,
record
):
if
isinstance
(
defitem
,
record
):
...
@@ -1089,7 +1090,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1089,7 +1090,7 @@ class HTTPRequest(BaseRequest):
a
=
a
.
split
(
":"
)
a
=
a
.
split
(
":"
)
a
,
new
=
':'
.
join
(
a
[:
-
1
]),
a
[
-
1
]
a
,
new
=
':'
.
join
(
a
[:
-
1
]),
a
[
-
1
]
attr
=
new
attr
=
new
if
form
.
has_key
(
k
)
:
if
k
in
form
:
# If the form has the split key get its value
# If the form has the split key get its value
tainted_split_key
=
k
tainted_split_key
=
k
if
'<'
in
k
:
if
'<'
in
k
:
...
@@ -1113,7 +1114,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1113,7 +1114,7 @@ class HTTPRequest(BaseRequest):
setattr
(
x
,
attr
,
value
)
setattr
(
x
,
attr
,
value
)
# Do the same for the tainted counterpart
# Do the same for the tainted counterpart
if
tainted
form
.
has_key
(
tainted_split_key
)
:
if
tainted
_split_key
in
taintedform
:
tainted
=
taintedform
[
tainted_split_key
]
tainted
=
taintedform
[
tainted_split_key
]
if
isinstance
(
item
,
record
):
if
isinstance
(
item
,
record
):
seq
=
tuple
(
getattr
(
tainted
,
attr
))
seq
=
tuple
(
getattr
(
tainted
,
attr
))
...
@@ -1129,19 +1130,19 @@ class HTTPRequest(BaseRequest):
...
@@ -1129,19 +1130,19 @@ class HTTPRequest(BaseRequest):
tainted_key
=
key
tainted_key
=
key
if
'<'
in
key
:
if
'<'
in
key
:
tainted_key
=
TaintedString
(
key
)
tainted_key
=
TaintedString
(
key
)
if
form
.
has_key
(
key
)
:
if
key
in
form
:
# if it has the original key, get the item
# if it has the original key, get the item
# convert it to a tuple
# convert it to a tuple
item
=
form
[
key
]
item
=
form
[
key
]
item
=
tuple
(
form
[
key
])
item
=
tuple
(
form
[
key
])
form
[
key
]
=
item
form
[
key
]
=
item
if
tainted
form
.
has_key
(
tainted_key
)
:
if
tainted
_key
in
taintedform
:
tainted
=
tuple
(
taintedform
[
tainted_key
])
tainted
=
tuple
(
taintedform
[
tainted_key
])
taintedform
[
tainted_key
]
=
tainted
taintedform
[
tainted_key
]
=
tainted
if
meth
:
if
meth
:
if
environ
.
has_key
(
'PATH_INFO'
)
:
if
'PATH_INFO'
in
environ
:
path
=
environ
[
'PATH_INFO'
]
path
=
environ
[
'PATH_INFO'
]
while
path
[
-
1
:]
==
'/'
:
while
path
[
-
1
:]
==
'/'
:
path
=
path
[:
-
1
]
path
=
path
[:
-
1
]
...
@@ -1253,7 +1254,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1253,7 +1254,7 @@ class HTTPRequest(BaseRequest):
"""
#"
"""
#"
other
=
self
.
other
other
=
self
.
other
if
other
.
has_key
(
key
)
:
if
key
in
other
:
if
key
==
'REQUEST'
:
if
key
==
'REQUEST'
:
return
self
return
self
return
other
[
key
]
return
other
[
key
]
...
@@ -1271,15 +1272,15 @@ class HTTPRequest(BaseRequest):
...
@@ -1271,15 +1272,15 @@ class HTTPRequest(BaseRequest):
else
:
else
:
path
=
[
other
[
'SERVER_URL'
]]
+
path
[:
n
]
path
=
[
other
[
'SERVER_URL'
]]
+
path
[:
n
]
URL
=
'/'
.
join
(
path
)
URL
=
'/'
.
join
(
path
)
if
other
.
has_key
(
'PUBLISHED'
)
:
if
'PUBLISHED'
in
other
:
# Don't cache URLs until publishing traversal is done.
# Don't cache URLs until publishing traversal is done.
other
[
key
]
=
URL
other
[
key
]
=
URL
self
.
_urls
=
self
.
_urls
+
(
key
,)
self
.
_urls
=
self
.
_urls
+
(
key
,)
return
URL
return
URL
if
isCGI_NAME
(
key
)
or
key
[:
5
]
==
'HTTP_'
:
if
key
in
isCGI_NAMEs
or
key
[:
5
]
==
'HTTP_'
:
environ
=
self
.
environ
environ
=
self
.
environ
if
environ
.
has_key
(
key
)
and
(
not
hide_key
(
key
)
):
if
key
in
environ
and
(
key
not
in
hide_key
):
return
environ
[
key
]
return
environ
[
key
]
return
''
return
''
...
@@ -1305,7 +1306,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1305,7 +1306,7 @@ class HTTPRequest(BaseRequest):
else
:
else
:
v
.
insert
(
0
,
other
[
'SERVER_URL'
])
v
.
insert
(
0
,
other
[
'SERVER_URL'
])
URL
=
'/'
.
join
(
v
)
URL
=
'/'
.
join
(
v
)
if
other
.
has_key
(
'PUBLISHED'
)
:
if
'PUBLISHED'
in
other
:
# Don't cache URLs until publishing traversal is done.
# Don't cache URLs until publishing traversal is done.
other
[
key
]
=
URL
other
[
key
]
=
URL
self
.
_urls
=
self
.
_urls
+
(
key
,)
self
.
_urls
=
self
.
_urls
+
(
key
,)
...
@@ -1406,7 +1407,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1406,7 +1407,7 @@ class HTTPRequest(BaseRequest):
keys
.
update
(
self
.
_lazies
)
keys
.
update
(
self
.
_lazies
)
for
key
in
self
.
environ
.
keys
():
for
key
in
self
.
environ
.
keys
():
if
(
isCGI_NAME
(
key
)
or
key
[:
5
]
==
'HTTP_'
)
and
(
not
hide_key
(
key
)
):
if
(
key
in
isCGI_NAMEs
or
key
[:
5
]
==
'HTTP_'
)
and
(
key
not
in
hide_key
):
keys
[
key
]
=
1
keys
[
key
]
=
1
# Cache URLN and BASEN in self.other.
# Cache URLN and BASEN in self.other.
...
@@ -1470,7 +1471,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1470,7 +1471,7 @@ class HTTPRequest(BaseRequest):
result
=
result
+
"</table><h3>environ</h3><table>"
result
=
result
+
"</table><h3>environ</h3><table>"
for
k
,
v
in
self
.
environ
.
items
():
for
k
,
v
in
self
.
environ
.
items
():
if
not
hide_key
(
k
)
:
if
k
not
in
hide_key
:
result
=
result
+
row
%
(
escape
(
k
),
escape
(
repr
(
v
)))
result
=
result
+
row
%
(
escape
(
k
),
escape
(
repr
(
v
)))
return
result
+
"</table>"
return
result
+
"</table>"
...
@@ -1509,7 +1510,7 @@ class HTTPRequest(BaseRequest):
...
@@ -1509,7 +1510,7 @@ class HTTPRequest(BaseRequest):
result
=
result
+
"
\
n
ENVIRON
\
n
\
n
"
result
=
result
+
"
\
n
ENVIRON
\
n
\
n
"
for
k
,
v
in
self
.
environ
.
items
():
for
k
,
v
in
self
.
environ
.
items
():
if
not
hide_key
(
k
)
:
if
k
not
in
hide_key
:
result
=
result
+
row
%
(
k
,
v
)
result
=
result
+
row
%
(
k
,
v
)
return
result
return
result
...
@@ -1575,7 +1576,7 @@ def sane_environment(env):
...
@@ -1575,7 +1576,7 @@ def sane_environment(env):
while
key
[:
9
]
==
'REDIRECT_'
:
while
key
[:
9
]
==
'REDIRECT_'
:
key
=
key
[
9
:]
key
=
key
[
9
:]
dict
[
key
]
=
val
dict
[
key
]
=
val
if
dict
.
has_key
(
'HTTP_CGI_AUTHORIZATION'
)
:
if
'HTTP_CGI_AUTHORIZATION'
in
dict
:
dict
[
'HTTP_AUTHORIZATION'
]
=
dict
[
'HTTP_CGI_AUTHORIZATION'
]
dict
[
'HTTP_AUTHORIZATION'
]
=
dict
[
'HTTP_CGI_AUTHORIZATION'
]
try
:
try
:
del
dict
[
'HTTP_CGI_AUTHORIZATION'
]
del
dict
[
'HTTP_CGI_AUTHORIZATION'
]
...
@@ -1661,7 +1662,6 @@ def parse_cookie(text,
...
@@ -1661,7 +1662,6 @@ def parse_cookie(text,
if
result
is
None
:
if
result
is
None
:
result
=
{}
result
=
{}
already_have
=
result
.
has_key
acquire
()
acquire
()
try
:
try
:
...
@@ -1694,7 +1694,7 @@ def parse_cookie(text,
...
@@ -1694,7 +1694,7 @@ def parse_cookie(text,
finally
:
finally
:
release
()
release
()
if
n
ot
already_have
(
name
)
:
if
n
ame
not
in
result
:
result
[
name
]
=
unquote
(
value
)
result
[
name
]
=
unquote
(
value
)
return
apply
(
parse_cookie
,(
text
[
l
:],
result
))
return
apply
(
parse_cookie
,(
text
[
l
:],
result
))
...
...
src/ZPublisher/HTTPResponse.py
View file @
c244e98a
...
@@ -220,7 +220,7 @@ class HTTPResponse(BaseResponse):
...
@@ -220,7 +220,7 @@ class HTTPResponse(BaseResponse):
if
isinstance
(
status
,
str
):
if
isinstance
(
status
,
str
):
status
=
status
.
lower
()
status
=
status
.
lower
()
if
status
_codes
.
has_key
(
status
)
:
if
status
in
status_codes
:
status
=
status_codes
[
status
]
status
=
status_codes
[
status
]
else
:
else
:
status
=
500
status
=
500
...
@@ -228,7 +228,7 @@ class HTTPResponse(BaseResponse):
...
@@ -228,7 +228,7 @@ class HTTPResponse(BaseResponse):
self
.
status
=
status
self
.
status
=
status
if
reason
is
None
:
if
reason
is
None
:
if
status
_reasons
.
has_key
(
status
)
:
if
status
in
status_reasons
:
reason
=
status_reasons
[
status
]
reason
=
status_reasons
[
status
]
else
:
else
:
reason
=
'Unknown'
reason
=
'Unknown'
...
@@ -252,7 +252,7 @@ class HTTPResponse(BaseResponse):
...
@@ -252,7 +252,7 @@ class HTTPResponse(BaseResponse):
value
=
str
(
value
)
value
=
str
(
value
)
cookies
=
self
.
cookies
cookies
=
self
.
cookies
if
cookies
.
has_key
(
name
)
:
if
name
in
cookies
:
cookie
=
cookies
[
name
]
cookie
=
cookies
[
name
]
else
:
else
:
cookie
=
cookies
[
name
]
=
{}
cookie
=
cookies
[
name
]
=
{}
...
@@ -273,11 +273,11 @@ class HTTPResponse(BaseResponse):
...
@@ -273,11 +273,11 @@ class HTTPResponse(BaseResponse):
value
=
str
(
value
)
value
=
str
(
value
)
cookies
=
self
.
cookies
cookies
=
self
.
cookies
if
cookies
.
has_key
(
name
)
:
if
name
in
cookies
:
cookie
=
cookies
[
name
]
cookie
=
cookies
[
name
]
else
:
else
:
cookie
=
cookies
[
name
]
=
{}
cookie
=
cookies
[
name
]
=
{}
if
cookie
.
has_key
(
'value'
)
:
if
'value'
in
cookie
:
cookie
[
'value'
]
=
'%s:%s'
%
(
cookie
[
'value'
],
value
)
cookie
[
'value'
]
=
'%s:%s'
%
(
cookie
[
'value'
],
value
)
else
:
else
:
cookie
[
'value'
]
=
value
cookie
[
'value'
]
=
value
...
@@ -351,7 +351,7 @@ class HTTPResponse(BaseResponse):
...
@@ -351,7 +351,7 @@ class HTTPResponse(BaseResponse):
name
=
name
.
lower
()
name
=
name
.
lower
()
headers
=
self
.
headers
headers
=
self
.
headers
if
headers
.
has_key
(
name
)
:
if
name
in
headers
:
h
=
headers
[
name
]
h
=
headers
[
name
]
h
=
"%s%s%s"
%
(
h
,
delimiter
,
value
)
h
=
"%s%s%s"
%
(
h
,
delimiter
,
value
)
else
:
else
:
...
...
src/ZPublisher/Publish.py
View file @
c244e98a
...
@@ -286,7 +286,7 @@ def get_module_info(module_name, modules={},
...
@@ -286,7 +286,7 @@ def get_module_info(module_name, modules={},
release
=
_l
.
release
,
release
=
_l
.
release
,
):
):
if
module
s
.
has_key
(
module_name
)
:
return
modules
[
module_name
]
if
module
_name
in
modules
:
return
modules
[
module_name
]
if
module_name
[
-
4
:]
==
'.cgi'
:
module_name
=
module_name
[:
-
4
]
if
module_name
[
-
4
:]
==
'.cgi'
:
module_name
=
module_name
[:
-
4
]
...
...
src/ZTUtils/Zope.py
View file @
c244e98a
...
@@ -297,18 +297,17 @@ def url_query(request, req_name="URL", omit=None):
...
@@ -297,18 +297,17 @@ def url_query(request, req_name="URL", omit=None):
omits
=
{}
omits
=
{}
for
name
in
omit
:
for
name
in
omit
:
omits
[
name
]
=
None
omits
[
name
]
=
None
omitted
=
omits
.
has_key
unq
=
urllib
.
unquote
unq
=
urllib
.
unquote
for
i
in
range
(
len
(
qsparts
)):
for
i
in
range
(
len
(
qsparts
)):
name
=
unq
(
qsparts
[
i
].
split
(
'='
,
1
)[
0
])
name
=
unq
(
qsparts
[
i
].
split
(
'='
,
1
)[
0
])
if
omitted
(
name
)
:
if
name
in
omits
:
qsparts
[
i
]
=
''
qsparts
[
i
]
=
''
name
=
name
.
split
(
':'
,
1
)[
0
]
name
=
name
.
split
(
':'
,
1
)[
0
]
if
omitted
(
name
)
:
if
name
in
omits
:
qsparts
[
i
]
=
''
qsparts
[
i
]
=
''
name
=
name
.
split
(
'.'
,
1
)[
0
]
name
=
name
.
split
(
'.'
,
1
)[
0
]
if
omitted
(
name
)
:
if
name
in
omits
:
qsparts
[
i
]
=
''
qsparts
[
i
]
=
''
qs
=
'&'
.
join
(
filter
(
None
,
qsparts
))
qs
=
'&'
.
join
(
filter
(
None
,
qsparts
))
...
...
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