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