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
74ac0363
Commit
74ac0363
authored
Oct 26, 2008
by
Sidnei da Silva
Browse files
Options
Browse Files
Download
Plain Diff
- Merge remaining changes from gsoc-python-2.5 branch. We now 'work' on Python 2.6
parents
3e91dac6
a6c2abea
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
352 additions
and
139 deletions
+352
-139
doc/CHANGES.txt
doc/CHANGES.txt
+19
-0
lib/python/AccessControl/ImplC.py
lib/python/AccessControl/ImplC.py
+8
-6
lib/python/AccessControl/ImplPython.py
lib/python/AccessControl/ImplPython.py
+2
-2
lib/python/AccessControl/ZopeGuards.py
lib/python/AccessControl/ZopeGuards.py
+15
-4
lib/python/AccessControl/__init__.py
lib/python/AccessControl/__init__.py
+10
-10
lib/python/AccessControl/cAccessControl.c
lib/python/AccessControl/cAccessControl.c
+1
-1
lib/python/AccessControl/tests/actual_python.py
lib/python/AccessControl/tests/actual_python.py
+11
-0
lib/python/AccessControl/tests/testZopeGuards.py
lib/python/AccessControl/tests/testZopeGuards.py
+37
-0
lib/python/Acquisition/_Acquisition.c
lib/python/Acquisition/_Acquisition.c
+37
-4
lib/python/DocumentTemplate/DT_HTML.py
lib/python/DocumentTemplate/DT_HTML.py
+4
-4
lib/python/DocumentTemplate/DT_If.py
lib/python/DocumentTemplate/DT_If.py
+1
-1
lib/python/DocumentTemplate/DT_In.py
lib/python/DocumentTemplate/DT_In.py
+10
-6
lib/python/DocumentTemplate/DT_InSV.py
lib/python/DocumentTemplate/DT_InSV.py
+2
-1
lib/python/DocumentTemplate/DT_Let.py
lib/python/DocumentTemplate/DT_Let.py
+3
-2
lib/python/DocumentTemplate/DT_Raise.py
lib/python/DocumentTemplate/DT_Raise.py
+11
-5
lib/python/DocumentTemplate/DT_Return.py
lib/python/DocumentTemplate/DT_Return.py
+1
-1
lib/python/DocumentTemplate/DT_String.py
lib/python/DocumentTemplate/DT_String.py
+4
-3
lib/python/DocumentTemplate/DT_Try.py
lib/python/DocumentTemplate/DT_Try.py
+3
-3
lib/python/DocumentTemplate/DT_UI.py
lib/python/DocumentTemplate/DT_UI.py
+1
-1
lib/python/DocumentTemplate/DT_Util.py
lib/python/DocumentTemplate/DT_Util.py
+24
-18
lib/python/DocumentTemplate/DT_Var.py
lib/python/DocumentTemplate/DT_Var.py
+7
-3
lib/python/DocumentTemplate/DT_With.py
lib/python/DocumentTemplate/DT_With.py
+4
-2
lib/python/DocumentTemplate/VSEval.py
lib/python/DocumentTemplate/VSEval.py
+1
-1
lib/python/DocumentTemplate/_DocumentTemplate.py
lib/python/DocumentTemplate/_DocumentTemplate.py
+3
-3
lib/python/DocumentTemplate/__init__.py
lib/python/DocumentTemplate/__init__.py
+2
-1
lib/python/DocumentTemplate/cDocumentTemplate.c
lib/python/DocumentTemplate/cDocumentTemplate.c
+1
-1
lib/python/DocumentTemplate/html_quote.py
lib/python/DocumentTemplate/html_quote.py
+1
-1
lib/python/DocumentTemplate/pDocumentTemplate.py
lib/python/DocumentTemplate/pDocumentTemplate.py
+1
-1
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+1
-1
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+17
-6
lib/python/OFS/tests/testCopySupport.py
lib/python/OFS/tests/testCopySupport.py
+1
-1
lib/python/Products/Five/testbrowser.py
lib/python/Products/Five/testbrowser.py
+7
-1
lib/python/Products/PythonScripts/tests/testPythonScript.py
lib/python/Products/PythonScripts/tests/testPythonScript.py
+14
-8
lib/python/Shared/DC/ZRDB/sqlvar.py
lib/python/Shared/DC/ZRDB/sqlvar.py
+5
-4
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+1
-1
lib/python/ZPublisher/tests/testPublish.py
lib/python/ZPublisher/tests/testPublish.py
+2
-1
lib/python/ZServer/HTTPServer.py
lib/python/ZServer/HTTPServer.py
+17
-4
lib/python/ZServer/medusa/http_server.py
lib/python/ZServer/medusa/http_server.py
+19
-19
lib/python/Zope2/App/startup.py
lib/python/Zope2/App/startup.py
+3
-2
lib/python/Zope2/App/tests/testExceptionHook.py
lib/python/Zope2/App/tests/testExceptionHook.py
+10
-2
lib/python/zExceptions/__init__.py
lib/python/zExceptions/__init__.py
+28
-1
utilities/mkzopeinstance.py
utilities/mkzopeinstance.py
+3
-3
No files found.
doc/CHANGES.txt
View file @
74ac0363
...
@@ -219,6 +219,13 @@ Zope Changes
...
@@ -219,6 +219,13 @@ Zope Changes
Bugs Fixed
Bugs Fixed
- Launchpad #280334: Fixed problem with 'timeout'
argument/attribute missing in testbrowser tests.
- Launchpad #282677: fixed implementation of guarded_map and
provided tests and implementation for guarded_zip (RestrictedPython).
- Lauchpad #143736,#271395: fixed AttributeError' on _ltid in TempStorage
- Lauchpad #143736,#271395: fixed AttributeError' on _ltid in TempStorage
- 'AccessControl.ZopeGuards.guarded_import' mapped some Unauthorized
- 'AccessControl.ZopeGuards.guarded_import' mapped some Unauthorized
...
@@ -475,6 +482,18 @@ Zope Changes
...
@@ -475,6 +482,18 @@ Zope Changes
- Prevent ZPublisher from insering incorrect <base/> tags into the
- Prevent ZPublisher from insering incorrect <base/> tags into the
headers of plain html files served from Zope3 resource directories.
headers of plain html files served from Zope3 resource directories.
- Changed the condition checking for setting status of
HTTPResponse from to account for new-style classes.
- The Wrapper_compare function from tp_compare to tp_richcompare.
Also another function Wrapper_richcompare is added.
- The doc test has been slightly changed in ZPublisher to get
the error message extracted correctly.
- The changes made in Acquisition.c in Implicit Acquisition
comparison made avail to Explicit Acquisition comparison also.
- zopedoctest no longer breaks if the URL contains more than one
- zopedoctest no longer breaks if the URL contains more than one
question mark. It broke even when the second question mark was
question mark. It broke even when the second question mark was
...
...
lib/python/AccessControl/ImplC.py
View file @
74ac0363
...
@@ -15,19 +15,21 @@
...
@@ -15,19 +15,21 @@
try
:
try
:
from
cAccessControl
import
rolesForPermissionOn
,
\
from
AccessControl.
cAccessControl
import
rolesForPermissionOn
,
\
PermissionRole
,
imPermissionRole
,
_what_not_even_god_should_do
,
\
PermissionRole
,
imPermissionRole
,
_what_not_even_god_should_do
,
\
RestrictedDTMLMixin
,
aq_validate
,
guarded_getattr
,
\
RestrictedDTMLMixin
,
aq_validate
,
guarded_getattr
,
\
setDefaultBehaviors
setDefaultBehaviors
from
cAccessControl
import
ZopeSecurityPolicy
as
cZopeSecurityPolicy
from
AccessControl.cAccessControl
import
ZopeSecurityPolicy
\
from
cAccessControl
import
SecurityManager
as
cSecurityManager
as
cZopeSecurityPolicy
from
AccessControl.cAccessControl
import
SecurityManager
as
cSecurityManager
except
ImportError
:
except
ImportError
:
import
sys
import
sys
# make sure a partial import doesn't pollute sys.modules
# make sure a partial import doesn't pollute sys.modules
del
sys
.
modules
[
__name__
]
del
sys
.
modules
[
__name__
]
raise
from
ImplPython
import
RestrictedDTML
,
SecurityManager
,
ZopeSecurityPolicy
from
AccessControl.ImplPython
import
RestrictedDTML
from
AccessControl.ImplPython
import
SecurityManager
,
ZopeSecurityPolicy
class
RestrictedDTML
(
RestrictedDTMLMixin
,
RestrictedDTML
):
class
RestrictedDTML
(
RestrictedDTMLMixin
,
RestrictedDTML
):
...
...
lib/python/AccessControl/ImplPython.py
View file @
74ac0363
...
@@ -30,7 +30,7 @@ try:
...
@@ -30,7 +30,7 @@ try:
except
ImportError
:
except
ImportError
:
_what_not_even_god_should_do
=
[]
_what_not_even_god_should_do
=
[]
from
AccessControl
import
SecurityManagement
from
AccessControl
.SecurityManagement
import
getSecurityManager
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
from
AccessControl.interfaces
import
ISecurityPolicy
from
AccessControl.interfaces
import
ISecurityPolicy
from
AccessControl.interfaces
import
ISecurityManager
from
AccessControl.interfaces
import
ISecurityManager
...
@@ -721,7 +721,7 @@ def guarded_getattr(inst, name, default=_marker):
...
@@ -721,7 +721,7 @@ def guarded_getattr(inst, name, default=_marker):
# See if we can get the value doing a filtered acquire.
# See if we can get the value doing a filtered acquire.
# aq_acquire will either return the same value as held by
# aq_acquire will either return the same value as held by
# v or it will return an Unauthorized raised by validate.
# v or it will return an Unauthorized raised by validate.
validate
=
SecurityManagement
.
getSecurityManager
().
validate
validate
=
getSecurityManager
().
validate
aq_acquire
(
inst
,
name
,
aq_validate
,
validate
)
aq_acquire
(
inst
,
name
,
aq_validate
,
validate
)
return
v
return
v
...
...
lib/python/AccessControl/ZopeGuards.py
View file @
74ac0363
...
@@ -237,18 +237,18 @@ def guarded_reduce(f, seq, initial=_marker):
...
@@ -237,18 +237,18 @@ def guarded_reduce(f, seq, initial=_marker):
return
reduce
(
f
,
guarded_iter
(
seq
),
initial
)
return
reduce
(
f
,
guarded_iter
(
seq
),
initial
)
safe_builtins
[
'reduce'
]
=
guarded_reduce
safe_builtins
[
'reduce'
]
=
guarded_reduce
def
guarded_max
(
item
,
*
items
):
def
guarded_max
(
item
,
*
items
,
**
kw
):
if
items
:
if
items
:
item
=
[
item
]
item
=
[
item
]
item
.
extend
(
items
)
item
.
extend
(
items
)
return
max
(
guarded_iter
(
item
))
return
max
(
guarded_iter
(
item
)
,
**
kw
)
safe_builtins
[
'max'
]
=
guarded_max
safe_builtins
[
'max'
]
=
guarded_max
def
guarded_min
(
item
,
*
items
):
def
guarded_min
(
item
,
*
items
,
**
kw
):
if
items
:
if
items
:
item
=
[
item
]
item
=
[
item
]
item
.
extend
(
items
)
item
.
extend
(
items
)
return
min
(
guarded_iter
(
item
))
return
min
(
guarded_iter
(
item
)
,
**
kw
)
safe_builtins
[
'min'
]
=
guarded_min
safe_builtins
[
'min'
]
=
guarded_min
def
guarded_map
(
f
,
*
seqs
):
def
guarded_map
(
f
,
*
seqs
):
...
@@ -375,6 +375,17 @@ def builtin_guarded_apply(func, args=(), kws={}):
...
@@ -375,6 +375,17 @@ def builtin_guarded_apply(func, args=(), kws={}):
safe_builtins
[
'apply'
]
=
builtin_guarded_apply
safe_builtins
[
'apply'
]
=
builtin_guarded_apply
# Similar to min and reduce, use guarded_iter on the sequence being
# tested and apply the original function.
if
sys
.
version_info
>=
(
2
,
5
):
def
guarded_any
(
seq
):
return
any
(
guarded_iter
(
seq
))
safe_builtins
[
'any'
]
=
guarded_any
def
guarded_all
(
seq
):
return
all
(
guarded_iter
(
seq
))
safe_builtins
[
'all'
]
=
guarded_all
# This metaclass supplies the security declarations that allow all
# This metaclass supplies the security declarations that allow all
# attributes of a class and its instances to be read and written.
# attributes of a class and its instances to be read and written.
def
_metaclass
(
name
,
bases
,
dict
):
def
_metaclass
(
name
,
bases
,
dict
):
...
...
lib/python/AccessControl/__init__.py
View file @
74ac0363
...
@@ -14,18 +14,18 @@
...
@@ -14,18 +14,18 @@
from
unauthorized
import
Unauthorized
from
unauthorized
import
Unauthorized
# This has to happen early so things get initialized properly
# This has to happen early so things get initialized properly
from
Implementation
import
setImplementation
from
AccessControl.
Implementation
import
setImplementation
from
SecurityManagement
import
getSecurityManager
,
setSecurityPolicy
from
AccessControl.
SecurityManagement
import
getSecurityManager
,
setSecurityPolicy
from
SecurityInfo
import
ClassSecurityInfo
,
ModuleSecurityInfo
from
AccessControl.
SecurityInfo
import
ClassSecurityInfo
,
ModuleSecurityInfo
from
SecurityInfo
import
ACCESS_PRIVATE
from
AccessControl.
SecurityInfo
import
ACCESS_PRIVATE
from
SecurityInfo
import
ACCESS_PUBLIC
from
AccessControl.
SecurityInfo
import
ACCESS_PUBLIC
from
SecurityInfo
import
ACCESS_NONE
from
AccessControl.
SecurityInfo
import
ACCESS_NONE
from
SecurityInfo
import
secureModule
,
allow_module
,
allow_class
from
AccessControl.
SecurityInfo
import
secureModule
,
allow_module
,
allow_class
from
SimpleObjectPolicies
import
allow_type
from
AccessControl.
SimpleObjectPolicies
import
allow_type
from
ZopeGuards
import
full_write_guard
,
safe_builtins
from
AccessControl.
ZopeGuards
import
full_write_guard
,
safe_builtins
ModuleSecurityInfo
(
'AccessControl'
).
declarePublic
(
'getSecurityManager'
)
ModuleSecurityInfo
(
'AccessControl'
).
declarePublic
(
'getSecurityManager'
)
import
DTML
from
AccessControl
import
DTML
del
DTML
del
DTML
lib/python/AccessControl/cAccessControl.c
View file @
74ac0363
...
@@ -2301,7 +2301,7 @@ void initcAccessControl(void) {
...
@@ -2301,7 +2301,7 @@ void initcAccessControl(void) {
/*| from logger_wrapper import warn
/*| from logger_wrapper import warn
*/
*/
IMPORT
(
module
,
"logger_wrapper"
);
IMPORT
(
module
,
"
AccessControl.
logger_wrapper"
);
GETATTR
(
module
,
warn
);
GETATTR
(
module
,
warn
);
Py_DECREF
(
module
);
Py_DECREF
(
module
);
module
=
NULL
;
module
=
NULL
;
...
...
lib/python/AccessControl/tests/actual_python.py
View file @
74ac0363
...
@@ -163,3 +163,14 @@ def f11():
...
@@ -163,3 +163,14 @@ def f11():
x
+=
1
x
+=
1
f11
()
f11
()
def
f12
():
assert
all
([
True
,
True
,
True
])
==
True
assert
all
([
True
,
False
,
True
])
==
False
f12
()
def
f13
():
assert
any
([
True
,
True
,
True
])
==
True
assert
any
([
True
,
False
,
True
])
==
True
assert
any
([
False
,
False
,
False
])
==
False
f13
()
lib/python/AccessControl/tests/testZopeGuards.py
View file @
74ac0363
...
@@ -31,6 +31,9 @@ from AccessControl.ZopeGuards \
...
@@ -31,6 +31,9 @@ from AccessControl.ZopeGuards \
get_iter
,
guarded_min
,
guarded_max
,
safe_builtins
,
guarded_enumerate
,
\
get_iter
,
guarded_min
,
guarded_max
,
safe_builtins
,
guarded_enumerate
,
\
guarded_sum
,
guarded_apply
,
guarded_map
,
guarded_zip
guarded_sum
,
guarded_apply
,
guarded_map
,
guarded_zip
if
sys
.
version_info
>=
(
2
,
5
):
from
AccessControl.ZopeGuards
import
guarded_any
,
guarded_all
try
:
try
:
__file__
__file__
except
NameError
:
except
NameError
:
...
@@ -253,11 +256,26 @@ class TestBuiltinFunctionGuards(GuardTestCase):
...
@@ -253,11 +256,26 @@ class TestBuiltinFunctionGuards(GuardTestCase):
[
1
,
2
,
3
],
[
3
,
2
,
1
])
[
1
,
2
,
3
],
[
3
,
2
,
1
])
self
.
setSecurityManager
(
old
)
self
.
setSecurityManager
(
old
)
if
sys
.
version_info
>=
(
2
,
5
):
def
test_all_fails
(
self
):
sm
=
SecurityManager
(
1
)
# rejects
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertRaises
(
Unauthorized
,
guarded_all
,
[
True
,
True
,
False
])
self
.
setSecurityManager
(
old
)
def
test_any_fails
(
self
):
sm
=
SecurityManager
(
1
)
# rejects
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertRaises
(
Unauthorized
,
guarded_any
,
[
True
,
True
,
False
])
self
.
setSecurityManager
(
old
)
def
test_min_fails
(
self
):
def
test_min_fails
(
self
):
sm
=
SecurityManager
(
1
)
# rejects
sm
=
SecurityManager
(
1
)
# rejects
old
=
self
.
setSecurityManager
(
sm
)
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertRaises
(
Unauthorized
,
guarded_min
,
[
1
,
2
,
3
])
self
.
assertRaises
(
Unauthorized
,
guarded_min
,
[
1
,
2
,
3
])
self
.
assertRaises
(
Unauthorized
,
guarded_min
,
1
,
2
,
3
)
self
.
assertRaises
(
Unauthorized
,
guarded_min
,
1
,
2
,
3
)
self
.
assertRaises
(
Unauthorized
,
guarded_min
,
[{
'x'
:
1
},{
'x'
:
2
}],
operator
.
itemgetter
(
'x'
))
self
.
setSecurityManager
(
old
)
self
.
setSecurityManager
(
old
)
def
test_max_fails
(
self
):
def
test_max_fails
(
self
):
...
@@ -265,6 +283,8 @@ class TestBuiltinFunctionGuards(GuardTestCase):
...
@@ -265,6 +283,8 @@ class TestBuiltinFunctionGuards(GuardTestCase):
old
=
self
.
setSecurityManager
(
sm
)
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertRaises
(
Unauthorized
,
guarded_max
,
[
1
,
2
,
3
])
self
.
assertRaises
(
Unauthorized
,
guarded_max
,
[
1
,
2
,
3
])
self
.
assertRaises
(
Unauthorized
,
guarded_max
,
1
,
2
,
3
)
self
.
assertRaises
(
Unauthorized
,
guarded_max
,
1
,
2
,
3
)
self
.
assertRaises
(
Unauthorized
,
guarded_max
,
[{
'x'
:
1
},{
'x'
:
2
}],
operator
.
itemgetter
(
'x'
))
self
.
setSecurityManager
(
old
)
self
.
setSecurityManager
(
old
)
def
test_enumerate_fails
(
self
):
def
test_enumerate_fails
(
self
):
...
@@ -295,11 +315,26 @@ class TestBuiltinFunctionGuards(GuardTestCase):
...
@@ -295,11 +315,26 @@ class TestBuiltinFunctionGuards(GuardTestCase):
[
4
,
4
,
4
])
[
4
,
4
,
4
])
self
.
setSecurityManager
(
old
)
self
.
setSecurityManager
(
old
)
if
sys
.
version_info
>=
(
2
,
5
):
def
test_all_succeeds
(
self
):
sm
=
SecurityManager
()
# accepts
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertEqual
(
guarded_all
([
True
,
True
,
False
]),
False
)
self
.
setSecurityManager
(
old
)
def
test_any_succeeds
(
self
):
sm
=
SecurityManager
()
# accepts
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertEquals
(
guarded_any
([
True
,
True
,
False
]),
True
)
self
.
setSecurityManager
(
old
)
def
test_min_succeeds
(
self
):
def
test_min_succeeds
(
self
):
sm
=
SecurityManager
()
# accepts
sm
=
SecurityManager
()
# accepts
old
=
self
.
setSecurityManager
(
sm
)
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertEqual
(
guarded_min
([
1
,
2
,
3
]),
1
)
self
.
assertEqual
(
guarded_min
([
1
,
2
,
3
]),
1
)
self
.
assertEqual
(
guarded_min
(
1
,
2
,
3
),
1
)
self
.
assertEqual
(
guarded_min
(
1
,
2
,
3
),
1
)
self
.
assertEqual
(
guarded_min
({
'x'
:
1
},{
'x'
:
2
},
key
=
operator
.
itemgetter
(
'x'
)),
{
'x'
:
1
})
self
.
setSecurityManager
(
old
)
self
.
setSecurityManager
(
old
)
def
test_max_succeeds
(
self
):
def
test_max_succeeds
(
self
):
...
@@ -307,6 +342,8 @@ class TestBuiltinFunctionGuards(GuardTestCase):
...
@@ -307,6 +342,8 @@ class TestBuiltinFunctionGuards(GuardTestCase):
old
=
self
.
setSecurityManager
(
sm
)
old
=
self
.
setSecurityManager
(
sm
)
self
.
assertEqual
(
guarded_max
([
1
,
2
,
3
]),
3
)
self
.
assertEqual
(
guarded_max
([
1
,
2
,
3
]),
3
)
self
.
assertEqual
(
guarded_max
(
1
,
2
,
3
),
3
)
self
.
assertEqual
(
guarded_max
(
1
,
2
,
3
),
3
)
self
.
assertEqual
(
guarded_max
({
'x'
:
1
},{
'x'
:
2
},
key
=
operator
.
itemgetter
(
'x'
)),
{
'x'
:
2
})
self
.
setSecurityManager
(
old
)
self
.
setSecurityManager
(
old
)
def
test_enumerate_succeeds
(
self
):
def
test_enumerate_succeeds
(
self
):
...
...
lib/python/Acquisition/_Acquisition.c
View file @
74ac0363
...
@@ -103,6 +103,32 @@ CallMethodO(PyObject *self, PyObject *name,
...
@@ -103,6 +103,32 @@ CallMethodO(PyObject *self, PyObject *name,
#define Build Py_BuildValue
#define Build Py_BuildValue
/* For obscure reasons, we need to use tp_richcompare instead of tp_compare.
* The comparisons here all most naturally compute a cmp()-like result.
* This little helper turns that into a bool result for rich comparisons.
*/
static
PyObject
*
diff_to_bool
(
int
diff
,
int
op
)
{
PyObject
*
result
;
int
istrue
;
switch
(
op
)
{
case
Py_EQ
:
istrue
=
diff
==
0
;
break
;
case
Py_NE
:
istrue
=
diff
!=
0
;
break
;
case
Py_LE
:
istrue
=
diff
<=
0
;
break
;
case
Py_GE
:
istrue
=
diff
>=
0
;
break
;
case
Py_LT
:
istrue
=
diff
<
0
;
break
;
case
Py_GT
:
istrue
=
diff
>
0
;
break
;
default:
assert
(
!
"op unknown"
);
istrue
=
0
;
/* To shut up compiler */
}
result
=
istrue
?
Py_True
:
Py_False
;
Py_INCREF
(
result
);
return
result
;
}
/* Declarations for objects of type Wrapper */
/* Declarations for objects of type Wrapper */
typedef
struct
{
typedef
struct
{
...
@@ -758,6 +784,13 @@ Wrapper_compare(Wrapper *self, PyObject *w)
...
@@ -758,6 +784,13 @@ Wrapper_compare(Wrapper *self, PyObject *w)
return
r
;
return
r
;
}
}
static
PyObject
*
Wrapper_richcompare
(
Wrapper
*
self
,
PyObject
*
w
,
int
op
)
{
int
diff
=
Wrapper_compare
(
self
,
w
);
return
diff_to_bool
(
diff
,
op
);
}
static
PyObject
*
static
PyObject
*
Wrapper_repr
(
Wrapper
*
self
)
Wrapper_repr
(
Wrapper
*
self
)
{
{
...
@@ -1241,7 +1274,7 @@ static PyExtensionClass Wrappertype = {
...
@@ -1241,7 +1274,7 @@ static PyExtensionClass Wrappertype = {
(
printfunc
)
0
,
/*tp_print*/
(
printfunc
)
0
,
/*tp_print*/
(
getattrfunc
)
0
,
/*tp_getattr*/
(
getattrfunc
)
0
,
/*tp_getattr*/
(
setattrfunc
)
0
,
/*tp_setattr*/
(
setattrfunc
)
0
,
/*tp_setattr*/
(
cmpfunc
)
Wrapper_compare
,
/*tp_compare*/
(
cmpfunc
)
0
,
/*tp_compare*/
(
reprfunc
)
Wrapper_repr
,
/*tp_repr*/
(
reprfunc
)
Wrapper_repr
,
/*tp_repr*/
&
Wrapper_as_number
,
/*tp_as_number*/
&
Wrapper_as_number
,
/*tp_as_number*/
&
Wrapper_as_sequence
,
/*tp_as_sequence*/
&
Wrapper_as_sequence
,
/*tp_as_sequence*/
...
@@ -1259,7 +1292,7 @@ static PyExtensionClass Wrappertype = {
...
@@ -1259,7 +1292,7 @@ static PyExtensionClass Wrappertype = {
"Wrapper object for implicit acquisition"
,
/* Documentation string */
"Wrapper object for implicit acquisition"
,
/* Documentation string */
/* tp_traverse */
(
traverseproc
)
Wrapper_traverse
,
/* tp_traverse */
(
traverseproc
)
Wrapper_traverse
,
/* tp_clear */
(
inquiry
)
Wrapper_clear
,
/* tp_clear */
(
inquiry
)
Wrapper_clear
,
/* tp_richcompare */
(
richcmpfunc
)
0
,
/* tp_richcompare */
(
richcmpfunc
)
Wrapper_richcompare
,
/* tp_weaklistoffset */
(
long
)
0
,
/* tp_weaklistoffset */
(
long
)
0
,
/* tp_iter */
(
getiterfunc
)
0
,
/* tp_iter */
(
getiterfunc
)
0
,
/* tp_iternext */
(
iternextfunc
)
0
,
/* tp_iternext */
(
iternextfunc
)
0
,
...
@@ -1285,7 +1318,7 @@ static PyExtensionClass XaqWrappertype = {
...
@@ -1285,7 +1318,7 @@ static PyExtensionClass XaqWrappertype = {
(
printfunc
)
0
,
/*tp_print*/
(
printfunc
)
0
,
/*tp_print*/
(
getattrfunc
)
0
,
/*tp_getattr*/
(
getattrfunc
)
0
,
/*tp_getattr*/
(
setattrfunc
)
0
,
/*tp_setattr*/
(
setattrfunc
)
0
,
/*tp_setattr*/
(
cmpfunc
)
Wrapper_compare
,
/*tp_compare*/
(
cmpfunc
)
0
,
/*tp_compare*/
(
reprfunc
)
Wrapper_repr
,
/*tp_repr*/
(
reprfunc
)
Wrapper_repr
,
/*tp_repr*/
&
Wrapper_as_number
,
/*tp_as_number*/
&
Wrapper_as_number
,
/*tp_as_number*/
&
Wrapper_as_sequence
,
/*tp_as_sequence*/
&
Wrapper_as_sequence
,
/*tp_as_sequence*/
...
@@ -1303,7 +1336,7 @@ static PyExtensionClass XaqWrappertype = {
...
@@ -1303,7 +1336,7 @@ static PyExtensionClass XaqWrappertype = {
"Wrapper object for implicit acquisition"
,
/* Documentation string */
"Wrapper object for implicit acquisition"
,
/* Documentation string */
/* tp_traverse */
(
traverseproc
)
Wrapper_traverse
,
/* tp_traverse */
(
traverseproc
)
Wrapper_traverse
,
/* tp_clear */
(
inquiry
)
Wrapper_clear
,
/* tp_clear */
(
inquiry
)
Wrapper_clear
,
/* tp_richcompare */
(
richcmpfunc
)
0
,
/* tp_richcompare */
(
richcmpfunc
)
Wrapper_richcompare
,
/* tp_weaklistoffset */
(
long
)
0
,
/* tp_weaklistoffset */
(
long
)
0
,
/* tp_iter */
(
getiterfunc
)
0
,
/* tp_iter */
(
getiterfunc
)
0
,
/* tp_iternext */
(
iternextfunc
)
0
,
/* tp_iternext */
(
iternextfunc
)
0
,
...
...
lib/python/DocumentTemplate/DT_HTML.py
View file @
74ac0363
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
$Id$"""
$Id$"""
from
DT_String
import
String
,
FileMixin
import
re
import
DT_String
,
re
from
DocumentTemplate.DT_String
import
String
,
FileMixin
from
DT_Util
import
ParseError
,
str
from
D
ocumentTemplate.D
T_Util
import
ParseError
,
str
class
dtml_re_class
:
class
dtml_re_class
:
""" This needs to be replaced before 2.4. It's a hackaround. """
""" This needs to be replaced before 2.4. It's a hackaround. """
...
@@ -129,7 +129,7 @@ class dtml_re_class:
...
@@ -129,7 +129,7 @@ class dtml_re_class:
def
start
(
self
,
*
args
):
def
start
(
self
,
*
args
):
return
self
.
_start
return
self
.
_start
class
HTML
(
DT_String
.
String
):
class
HTML
(
String
):
"""HTML Document Templates
"""HTML Document Templates
HTML Document templates use HTML server-side-include syntax,
HTML Document templates use HTML server-side-include syntax,
...
...
lib/python/DocumentTemplate/DT_If.py
View file @
74ac0363
...
@@ -78,7 +78,7 @@ __doc__='''Conditional insertion
...
@@ -78,7 +78,7 @@ __doc__='''Conditional insertion
__rcs_id__
=
'$Id$'
__rcs_id__
=
'$Id$'
__version__
=
'$Revision: 1.19 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.19 $'
[
11
:
-
2
]
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
from
D
ocumentTemplate.D
T_Util
import
ParseError
,
parse_params
,
name_param
,
str
class
If
:
class
If
:
blockContinuations
=
'else'
,
'elif'
blockContinuations
=
'else'
,
'elif'
...
...
lib/python/DocumentTemplate/DT_In.py
View file @
74ac0363
...
@@ -333,13 +333,17 @@ __rcs_id__='$Id$'
...
@@ -333,13 +333,17 @@ __rcs_id__='$Id$'
__version__
=
'$Revision: 1.62 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.62 $'
[
11
:
-
2
]
import
sys
import
sys
from
DT_Util
import
ParseError
,
parse_params
,
name_param
,
str
,
join_unicode
from
DT_Util
import
render_blocks
,
InstanceDict
,
ValidationError
,
Eval
from
DT_Util
import
simple_name
,
add_with_prefix
import
re
import
re
from
DT_InSV
import
sequence_variables
,
opt
TupleType
=
type
(())
from
DocumentTemplate.DT_Util
import
ParseError
,
parse_params
,
name_param
StringTypes
=
(
type
(
''
),
type
(
u''
))
from
DocumentTemplate.DT_Util
import
str
,
join_unicode
from
DocumentTemplate.DT_Util
import
render_blocks
,
InstanceDict
from
DocumentTemplate.DT_Util
import
ValidationError
,
Eval
from
DocumentTemplate.DT_Util
import
simple_name
,
add_with_prefix
from
DocumentTemplate.DT_InSV
import
sequence_variables
,
opt
TupleType
=
tuple
StringTypes
=
(
str
,
unicode
)
class
InFactory
:
class
InFactory
:
blockContinuations
=
(
'else'
,)
blockContinuations
=
(
'else'
,)
...
...
lib/python/DocumentTemplate/DT_InSV.py
View file @
74ac0363
...
@@ -18,12 +18,13 @@ __version__='$Revision: 1.22 $'[11:-2]
...
@@ -18,12 +18,13 @@ __version__='$Revision: 1.22 $'[11:-2]
from
math
import
sqrt
from
math
import
sqrt
import
re
import
re
TupleType
=
type
(())
try
:
try
:
import
Missing
import
Missing
mv
=
Missing
.
Value
mv
=
Missing
.
Value
except
:
mv
=
None
except
:
mv
=
None
TupleType
=
tuple
class
sequence_variables
:
class
sequence_variables
:
...
...
lib/python/DocumentTemplate/DT_Let.py
View file @
74ac0363
...
@@ -40,10 +40,11 @@
...
@@ -40,10 +40,11 @@
as desired.
as desired.
'''
'''
from
DT_Util
import
render_blocks
,
Eval
,
ParseError
from
DT_Util
import
str
# Probably needed due to hysterical pickles.
import
re
import
re
from
DocumentTemplate.DT_Util
import
render_blocks
,
Eval
,
ParseError
from
DocumentTemplate.DT_Util
import
str
# Probably needed due to
# hysterical pickles.
class
Let
:
class
Let
:
blockContinuations
=
()
blockContinuations
=
()
...
...
lib/python/DocumentTemplate/DT_Raise.py
View file @
74ac0363
...
@@ -26,7 +26,11 @@
...
@@ -26,7 +26,11 @@
__rcs_id__
=
'$Id$'
__rcs_id__
=
'$Id$'
__version__
=
'$Revision: 1.13 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.13 $'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
render_blocks
,
str
from
zExceptions
import
upgradeException
from
DocumentTemplate.DT_Util
import
parse_params
,
name_param
,
render_blocks
,
str
class
InvalidErrorTypeExpression
(
Exception
):
pass
class
Raise
:
class
Raise
:
blockContinuations
=
()
blockContinuations
=
()
...
@@ -44,15 +48,17 @@ class Raise:
...
@@ -44,15 +48,17 @@ class Raise:
expr
=
self
.
expr
expr
=
self
.
expr
if
expr
is
None
:
if
expr
is
None
:
t
=
self
.
__name__
t
=
self
.
__name__
if
t
[
-
5
:]
==
'Error'
and
__builtins__
.
has_key
(
t
):
t
=
__builtins__
[
t
]
else
:
else
:
try
:
t
=
expr
.
eval
(
md
)
try
:
t
=
expr
.
eval
(
md
)
except
:
t
=
'Invalid Error Type Expression'
except
:
t
=
InvalidErrorTypeExpression
try
:
v
=
render_blocks
(
self
.
section
,
md
)
try
:
v
=
render_blocks
(
self
.
section
,
md
)
except
:
v
=
'Invalid Error Value'
except
:
v
=
'Invalid Error Value'
# String Exceptions are deprecated on Python 2.5 and
# plain won't work at all on Python 2.6. So try to upgrade it
# to a real exception.
t
,
v
=
upgradeException
(
t
,
v
)
raise
t
,
v
raise
t
,
v
__call__
=
render
__call__
=
render
lib/python/DocumentTemplate/DT_Return.py
View file @
74ac0363
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
__version__
=
'$Revision: 1.9 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.9 $'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
from
D
ocumentTemplate.D
T_Util
import
parse_params
,
name_param
class
ReturnTag
:
class
ReturnTag
:
name
=
'return'
name
=
'return'
...
...
lib/python/DocumentTemplate/DT_String.py
View file @
74ac0363
...
@@ -16,9 +16,10 @@ import os
...
@@ -16,9 +16,10 @@ import os
import
thread
import
thread
import
re
import
re
from
DT_Util
import
ParseError
,
InstanceDict
,
TemplateDict
,
render_blocks
,
str
from
DocumentTemplate.DT_Util
import
ParseError
,
InstanceDict
from
DT_Var
import
Var
,
Call
,
Comment
from
DocumentTemplate.DT_Util
import
TemplateDict
,
render_blocks
,
str
from
DT_Return
import
ReturnTag
,
DTReturn
from
DocumentTemplate.DT_Var
import
Var
,
Call
,
Comment
from
DocumentTemplate.DT_Return
import
ReturnTag
,
DTReturn
_marker
=
[]
# Create a new marker object.
_marker
=
[]
# Create a new marker object.
...
...
lib/python/DocumentTemplate/DT_Try.py
View file @
74ac0363
...
@@ -13,9 +13,9 @@
...
@@ -13,9 +13,9 @@
import
sys
,
traceback
import
sys
,
traceback
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
from
DT_Util
import
ParseError
,
parse_params
,
render_blocks
from
D
ocumentTemplate.D
T_Util
import
ParseError
,
parse_params
,
render_blocks
from
DT_Util
import
namespace
,
InstanceDict
from
D
ocumentTemplate.D
T_Util
import
namespace
,
InstanceDict
from
DT_Return
import
DTReturn
from
D
ocumentTemplate.D
T_Return
import
DTReturn
class
Try
:
class
Try
:
"""Zope DTML Exception handling
"""Zope DTML Exception handling
...
...
lib/python/DocumentTemplate/DT_UI.py
View file @
74ac0363
...
@@ -15,7 +15,7 @@ __doc__='''Machinery to support through-the-web editing
...
@@ -15,7 +15,7 @@ __doc__='''Machinery to support through-the-web editing
$Id$'''
$Id$'''
__version__
=
'$Revision: 1.15 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.15 $'
[
11
:
-
2
]
from
DT_HTML
import
HTML
from
D
ocumentTemplate.D
T_HTML
import
HTML
FactoryDefaultString
=
"Factory Default"
FactoryDefaultString
=
"Factory Default"
...
...
lib/python/DocumentTemplate/DT_Util.py
View file @
74ac0363
...
@@ -16,12 +16,16 @@ $Id$"""
...
@@ -16,12 +16,16 @@ $Id$"""
import
re
import
re
from
html_quote
import
html_quote
,
ustr
# for import by other modules, dont remove!
# for import by other modules, dont remove!
from
DocumentTemplate.html_quote
import
html_quote
,
ustr
from
DocumentTemplate.cDocumentTemplate
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.cDocumentTemplate
import
render_blocks
,
safe_callable
from
DocumentTemplate.cDocumentTemplate
import
join_unicode
from
RestrictedPython.Guards
import
safe_builtins
from
RestrictedPython.Guards
import
safe_builtins
from
RestrictedPython.Utilities
import
utility_builtins
from
RestrictedPython.Utilities
import
utility_builtins
from
RestrictedPython.Eval
import
RestrictionCapableEval
from
RestrictedPython.Eval
import
RestrictionCapableEval
from
cDocumentTemplate
import
InstanceDict
,
TemplateDict
,
\
render_blocks
,
safe_callable
,
join_unicode
test
=
utility_builtins
[
'test'
]
# for backwards compatibility, dont remove!
test
=
utility_builtins
[
'test'
]
# for backwards compatibility, dont remove!
...
@@ -29,7 +33,9 @@ LIMITED_BUILTINS = 1
...
@@ -29,7 +33,9 @@ LIMITED_BUILTINS = 1
str
=
__builtins__
[
'str'
]
# Waaaaa, waaaaaaaa needed for pickling waaaaa
str
=
__builtins__
[
'str'
]
# Waaaaa, waaaaaaaa needed for pickling waaaaa
ParseError
=
'Document Template Parse Error'
class
ParseError
(
Exception
):
"""Document Template Parse Error"""
from
zExceptions
import
Unauthorized
as
ValidationError
from
zExceptions
import
Unauthorized
as
ValidationError
def
int_param
(
params
,
md
,
name
,
default
=
0
,
st
=
type
(
''
)):
def
int_param
(
params
,
md
,
name
,
default
=
0
,
st
=
type
(
''
)):
...
@@ -235,37 +241,37 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
...
@@ -235,37 +241,37 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
if
v
[:
1
]
==
'"'
and
v
[
-
1
:]
==
'"'
and
len
(
v
)
>
1
:
# expr shorthand
if
v
[:
1
]
==
'"'
and
v
[
-
1
:]
==
'"'
and
len
(
v
)
>
1
:
# expr shorthand
if
used
(
attr
):
if
used
(
attr
):
raise
ParseError
,
(
'%s and expr given'
%
attr
,
tag
)
raise
ParseError
(
'%s and expr given'
%
attr
,
tag
)
if
expr
:
if
expr
:
if
used
(
'expr'
):
if
used
(
'expr'
):
raise
ParseError
,
(
'two exprs given'
,
tag
)
raise
ParseError
(
'two exprs given'
,
tag
)
v
=
v
[
1
:
-
1
]
v
=
v
[
1
:
-
1
]
try
:
expr
=
Eval
(
v
)
try
:
expr
=
Eval
(
v
)
except
SyntaxError
,
v
:
except
SyntaxError
,
v
:
raise
ParseError
,
(
raise
ParseError
(
'<strong>Expression (Python) Syntax error</strong>:'
'<strong>Expression (Python) Syntax error</strong>:'
'
\
n
<pre>
\
n
%s
\
n
</pre>
\
n
'
%
v
[
0
],
'
\
n
<pre>
\
n
%s
\
n
</pre>
\
n
'
%
v
[
0
],
tag
)
tag
)
return
v
,
expr
return
v
,
expr
else
:
raise
ParseError
,
(
else
:
raise
ParseError
(
'The "..." shorthand for expr was used in a tag '
'The "..." shorthand for expr was used in a tag '
'that doesn
\
'
t support expr attributes.'
,
'that doesn
\
'
t support expr attributes.'
,
tag
)
tag
)
else
:
# name shorthand
else
:
# name shorthand
if
used
(
attr
):
if
used
(
attr
):
raise
ParseError
,
(
'Two %s values were given'
%
attr
,
tag
)
raise
ParseError
(
'Two %s values were given'
%
attr
,
tag
)
if
expr
:
if
expr
:
if
used
(
'expr'
):
if
used
(
'expr'
):
# raise 'Waaaaaa', 'waaa'
# raise 'Waaaaaa', 'waaa'
raise
ParseError
,
(
'%s and expr given'
%
attr
,
tag
)
raise
ParseError
(
'%s and expr given'
%
attr
,
tag
)
return
params
[
''
],
None
return
params
[
''
],
None
return
params
[
''
]
return
params
[
''
]
elif
used
(
attr
):
elif
used
(
attr
):
if
expr
:
if
expr
:
if
used
(
'expr'
):
if
used
(
'expr'
):
raise
ParseError
,
(
'%s and expr given'
%
attr
,
tag
)
raise
ParseError
(
'%s and expr given'
%
attr
,
tag
)
return
params
[
attr
],
None
return
params
[
attr
],
None
return
params
[
attr
]
return
params
[
attr
]
elif
expr
and
used
(
'expr'
):
elif
expr
and
used
(
'expr'
):
...
@@ -273,7 +279,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
...
@@ -273,7 +279,7 @@ def name_param(params,tag='',expr=0, attr='name', default_unnamed=1):
expr
=
Eval
(
name
)
expr
=
Eval
(
name
)
return
name
,
expr
return
name
,
expr
raise
ParseError
,
(
'No %s given'
%
attr
,
tag
)
raise
ParseError
(
'No %s given'
%
attr
,
tag
)
Expr_doc
=
"""
Expr_doc
=
"""
...
@@ -386,11 +392,11 @@ def parse_params(text,
...
@@ -386,11 +392,11 @@ def parse_params(text,
l
=
len
(
mo_unp
.
group
(
1
))
l
=
len
(
mo_unp
.
group
(
1
))
if
result
:
if
result
:
if
parms
.
has_key
(
name
):
if
parms
.
has_key
(
name
):
if
parms
[
name
]
is
None
:
raise
ParseError
,
(
if
parms
[
name
]
is
None
:
raise
ParseError
(
'Attribute %s requires a value'
%
name
,
tag
)
'Attribute %s requires a value'
%
name
,
tag
)
result
[
name
]
=
parms
[
name
]
result
[
name
]
=
parms
[
name
]
else
:
raise
ParseError
,
(
else
:
raise
ParseError
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
else
:
else
:
result
[
''
]
=
name
result
[
''
]
=
name
...
@@ -398,22 +404,22 @@ def parse_params(text,
...
@@ -398,22 +404,22 @@ def parse_params(text,
elif
mo_unq
:
elif
mo_unq
:
name
=
mo_unq
.
group
(
2
)
name
=
mo_unq
.
group
(
2
)
l
=
len
(
mo_unq
.
group
(
1
))
l
=
len
(
mo_unq
.
group
(
1
))
if
result
:
raise
ParseError
,
(
if
result
:
raise
ParseError
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
else
:
result
[
''
]
=
name
else
:
result
[
''
]
=
name
return
parse_params
(
text
[
l
:],
result
,
**
parms
)
return
parse_params
(
text
[
l
:],
result
,
**
parms
)
else
:
else
:
if
not
text
or
not
text
.
strip
():
return
result
if
not
text
or
not
text
.
strip
():
return
result
raise
ParseError
,
(
'invalid parameter: "%s"'
%
text
,
tag
)
raise
ParseError
(
'invalid parameter: "%s"'
%
text
,
tag
)
if
not
parms
.
has_key
(
name
):
if
not
parms
.
has_key
(
name
):
raise
ParseError
,
(
raise
ParseError
(
'Invalid attribute name, "%s"'
%
name
,
tag
)
'Invalid attribute name, "%s"'
%
name
,
tag
)
if
result
.
has_key
(
name
):
if
result
.
has_key
(
name
):
p
=
parms
[
name
]
p
=
parms
[
name
]
if
type
(
p
)
is
not
ListType
or
p
:
if
type
(
p
)
is
not
ListType
or
p
:
raise
ParseError
,
(
raise
ParseError
(
'Duplicate values for attribute "%s"'
%
name
,
tag
)
'Duplicate values for attribute "%s"'
%
name
,
tag
)
result
[
name
]
=
value
result
[
name
]
=
value
...
...
lib/python/DocumentTemplate/DT_Var.py
View file @
74ac0363
...
@@ -151,14 +151,18 @@ Evaluating expressions without rendering results
...
@@ -151,14 +151,18 @@ Evaluating expressions without rendering results
'''
# '
'''
# '
__rcs_id__
=
'$Id$'
__rcs_id__
=
'$Id$'
__version__
=
'$Revision: 1.60 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.60 $'
[
11
:
-
2
]
import
string
,
re
,
sys
from
cgi
import
escape
from
cgi
import
escape
import
string
,
re
,
sys
from
urllib
import
quote
,
quote_plus
,
unquote
,
unquote_plus
from
urllib
import
quote
,
quote_plus
,
unquote
,
unquote_plus
from
DT_Util
import
parse_params
,
name_param
,
str
,
ustr
from
html_quote
import
html_quote
# for import by other modules, dont remove!
# for import by other modules, dont remove!
from
DocumentTemplate.html_quote
import
html_quote
from
DocumentTemplate.DT_Util
import
parse_params
,
name_param
,
str
,
ustr
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
ZPublisher.TaintedString
import
TaintedString
from
ZPublisher.TaintedString
import
TaintedString
from
zope.structuredtext.html
import
HTMLWithImages
,
HTML
from
zope.structuredtext.html
import
HTMLWithImages
,
HTML
...
...
lib/python/DocumentTemplate/DT_With.py
View file @
74ac0363
...
@@ -36,8 +36,10 @@
...
@@ -36,8 +36,10 @@
__rcs_id__
=
'$Id$'
__rcs_id__
=
'$Id$'
__version__
=
'$Revision: 1.15 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.15 $'
[
11
:
-
2
]
from
DT_Util
import
parse_params
,
name_param
,
InstanceDict
,
render_blocks
,
str
from
DocumentTemplate.DT_Util
import
parse_params
,
name_param
from
DT_Util
import
TemplateDict
from
DocumentTemplate.DT_Util
import
InstanceDict
,
render_blocks
,
str
from
DocumentTemplate.DT_Util
import
TemplateDict
class
With
:
class
With
:
blockContinuations
=
()
blockContinuations
=
()
name
=
'with'
name
=
'with'
...
...
lib/python/DocumentTemplate/VSEval.py
View file @
74ac0363
# alias module for backwards compatibility
# alias module for backwards compatibility
from
DT_Util
import
Eval
from
D
ocumentTemplate.D
T_Util
import
Eval
def
careful_mul
(
env
,
*
factors
):
def
careful_mul
(
env
,
*
factors
):
r
=
1
r
=
1
...
...
lib/python/DocumentTemplate/DocumentTemplate.py
→
lib/python/DocumentTemplate/
_
DocumentTemplate.py
View file @
74ac0363
...
@@ -107,8 +107,8 @@ Document Templates may be created 4 ways:
...
@@ -107,8 +107,8 @@ Document Templates may be created 4 ways:
__version__
=
'$Revision: 1.14 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.14 $'
[
11
:
-
2
]
ParseError
=
'Document Template Parse Error'
from
DocumentTemplate.DT_Raise
import
ParseError
from
DocumentTemplate.DT_String
import
String
,
File
from
DocumentTemplate.DT_HTML
import
HTML
,
HTMLFile
,
HTMLDefault
from
DT_String
import
String
,
File
from
DT_HTML
import
HTML
,
HTMLFile
,
HTMLDefault
# import DT_UI # Install HTML editing
# import DT_UI # Install HTML editing
lib/python/DocumentTemplate/__init__.py
View file @
74ac0363
...
@@ -18,4 +18,5 @@ segregated in a separate package.
...
@@ -18,4 +18,5 @@ segregated in a separate package.
$Id$'''
$Id$'''
__version__
=
'$Revision: 1.18 $'
[
11
:
-
2
]
__version__
=
'$Revision: 1.18 $'
[
11
:
-
2
]
from
DocumentTemplate
import
String
,
File
,
HTML
,
HTMLDefault
,
HTMLFile
from
DocumentTemplate.DT_String
import
String
,
File
from
DocumentTemplate.DT_HTML
import
HTML
,
HTMLDefault
,
HTMLFile
lib/python/DocumentTemplate/cDocumentTemplate.c
View file @
74ac0363
...
@@ -972,7 +972,7 @@ initcDocumentTemplate(void)
...
@@ -972,7 +972,7 @@ initcDocumentTemplate(void)
DictInstanceType
.
ob_type
=&
PyType_Type
;
DictInstanceType
.
ob_type
=&
PyType_Type
;
UNLESS
(
html_quote
=
PyImport_ImportModule
(
"html_quote"
))
return
;
UNLESS
(
html_quote
=
PyImport_ImportModule
(
"
DocumentTemplate.
html_quote"
))
return
;
ASSIGN
(
ustr
,
PyObject_GetAttrString
(
html_quote
,
"ustr"
));
ASSIGN
(
ustr
,
PyObject_GetAttrString
(
html_quote
,
"ustr"
));
UNLESS
(
ustr
)
return
;
UNLESS
(
ustr
)
return
;
ASSIGN
(
html_quote
,
PyObject_GetAttrString
(
html_quote
,
"html_quote"
));
ASSIGN
(
html_quote
,
PyObject_GetAttrString
(
html_quote
,
"html_quote"
));
...
...
lib/python/DocumentTemplate/html_quote.py
View file @
74ac0363
# split off into its own module for aliasing without circrefs
# split off into its own module for aliasing without circrefs
from
cgi
import
escape
from
cgi
import
escape
from
ustr
import
ustr
from
DocumentTemplate.
ustr
import
ustr
def
html_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
def
html_quote
(
v
,
name
=
'(Unknown name)'
,
md
=
{}):
return
escape
(
ustr
(
v
),
1
)
return
escape
(
ustr
(
v
),
1
)
lib/python/DocumentTemplate/pDocumentTemplate.py
View file @
74ac0363
...
@@ -20,7 +20,7 @@ __version__='$Revision: 1.42 $'[11:-2]
...
@@ -20,7 +20,7 @@ __version__='$Revision: 1.42 $'[11:-2]
import
sys
,
types
import
sys
,
types
from
types
import
StringType
,
UnicodeType
,
TupleType
from
types
import
StringType
,
UnicodeType
,
TupleType
from
ustr
import
ustr
from
DocumentTemplate.
ustr
import
ustr
import
warnings
import
warnings
warnings
.
warn
(
'pDocumentTemplate is not longer in active use. '
warnings
.
warn
(
'pDocumentTemplate is not longer in active use. '
...
...
lib/python/OFS/CopySupport.py
View file @
74ac0363
...
@@ -48,7 +48,7 @@ from OFS.interfaces import ICopyContainer
...
@@ -48,7 +48,7 @@ from OFS.interfaces import ICopyContainer
from
OFS.interfaces
import
ICopySource
from
OFS.interfaces
import
ICopySource
CopyError
=
'Copy Error'
class
CopyError
(
Exception
):
pass
copy_re
=
re
.
compile
(
'^copy([0-9]*)_of_(.*)'
)
copy_re
=
re
.
compile
(
'^copy([0-9]*)_of_(.*)'
)
...
...
lib/python/OFS/SimpleItem.py
View file @
74ac0363
...
@@ -36,7 +36,7 @@ from DocumentTemplate.html_quote import html_quote
...
@@ -36,7 +36,7 @@ from DocumentTemplate.html_quote import html_quote
from
DocumentTemplate.ustr
import
ustr
from
DocumentTemplate.ustr
import
ustr
from
ExtensionClass
import
Base
from
ExtensionClass
import
Base
from
webdav.Resource
import
Resource
from
webdav.Resource
import
Resource
from
zExceptions
import
Redirect
from
zExceptions
import
Redirect
,
upgradeException
from
zExceptions.ExceptionFormatter
import
format_exception
from
zExceptions.ExceptionFormatter
import
format_exception
from
zope.interface
import
implements
from
zope.interface
import
implements
...
@@ -181,16 +181,24 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
...
@@ -181,16 +181,24 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
elif
type
(
tb
)
is
type
(
''
)
and
not
error_tb
:
elif
type
(
tb
)
is
type
(
''
)
and
not
error_tb
:
error_tb
=
tb
error_tb
=
tb
# turn error_type into a string
# warn if error_type is a string
if
hasattr
(
error_type
,
'__name__'
):
error_name
=
'Unknown'
error_type
=
error_type
.
__name__
if
isinstance
(
error_type
,
basestring
):
# String Exceptions are deprecated on Python 2.5 and
# plain won't work at all on Python 2.6. So try to upgrade it
# to a real exception.
error_name
=
error_type
error_type
,
error_value
=
upgradeException
(
error_type
,
error_value
)
else
:
if
hasattr
(
error_type
,
'__name__'
):
error_name
=
error_type
.
__name__
if
hasattr
(
self
,
'_v_eek'
):
if
hasattr
(
self
,
'_v_eek'
):
# Stop if there is recursion.
# Stop if there is recursion.
raise
error_type
,
error_value
,
tb
raise
error_type
,
error_value
,
tb
self
.
_v_eek
=
1
self
.
_v_eek
=
1
if
str
(
error_type
)
.
lower
()
in
(
'redirect'
,):
if
error_name
.
lower
()
in
(
'redirect'
,):
raise
error_type
,
error_value
,
tb
raise
error_type
,
error_value
,
tb
if
not
error_message
:
if
not
error_message
:
...
@@ -216,7 +224,10 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
...
@@ -216,7 +224,10 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
else
:
else
:
client
=
aq_parent
(
client
)
client
=
aq_parent
(
client
)
s
=
getattr
(
client
,
'standard_error_message'
)
s
=
getattr
(
client
,
'standard_error_message'
)
kwargs
=
{
'error_type'
:
error_type
,
# For backward compatibility, we pass 'error_name' as
# 'error_type' here as historically this has always
# been a string.
kwargs
=
{
'error_type'
:
error_name
,
'error_value'
:
error_value
,
'error_value'
:
error_value
,
'error_tb'
:
error_tb
,
'error_tb'
:
error_tb
,
'error_traceback'
:
error_tb
,
'error_traceback'
:
error_tb
,
...
...
lib/python/OFS/tests/testCopySupport.py
View file @
74ac0363
...
@@ -347,7 +347,7 @@ class TestCopySupportSecurity( CopySupportTestBase ):
...
@@ -347,7 +347,7 @@ class TestCopySupportSecurity( CopySupportTestBase ):
if
ce_regex
is
not
None
:
if
ce_regex
is
not
None
:
pattern
=
re
.
compile
(
ce_regex
,
re
.
DOTALL
)
pattern
=
re
.
compile
(
ce_regex
,
re
.
DOTALL
)
if
pattern
.
search
(
e
)
is
None
:
if
pattern
.
search
(
e
.
args
[
0
]
)
is
None
:
self
.
fail
(
"Paste failed; didn't match pattern:
\
n
%s"
%
e
)
self
.
fail
(
"Paste failed; didn't match pattern:
\
n
%s"
%
e
)
else
:
else
:
...
...
lib/python/Products/Five/testbrowser.py
View file @
74ac0363
...
@@ -18,6 +18,8 @@ Mostly just copy and paste from zope.testbrowser.testing.
...
@@ -18,6 +18,8 @@ Mostly just copy and paste from zope.testbrowser.testing.
$Id$
$Id$
"""
"""
import
sys
import
socket
import
urllib2
import
urllib2
import
mechanize
import
mechanize
...
@@ -29,7 +31,7 @@ import zope.publisher.http
...
@@ -29,7 +31,7 @@ import zope.publisher.http
class
PublisherConnection
(
testing
.
PublisherConnection
):
class
PublisherConnection
(
testing
.
PublisherConnection
):
def
__init__
(
self
,
host
):
def
__init__
(
self
,
host
,
timeout
=
None
):
from
Testing.ZopeTestCase.zopedoctest.functional
import
http
from
Testing.ZopeTestCase.zopedoctest.functional
import
http
self
.
caller
=
http
self
.
caller
=
http
self
.
host
=
host
self
.
host
=
host
...
@@ -76,6 +78,10 @@ class PublisherHTTPHandler(urllib2.HTTPHandler):
...
@@ -76,6 +78,10 @@ class PublisherHTTPHandler(urllib2.HTTPHandler):
def
http_open
(
self
,
req
):
def
http_open
(
self
,
req
):
"""Open an HTTP connection having a ``urllib2`` request."""
"""Open an HTTP connection having a ``urllib2`` request."""
# Here we connect to the publisher.
# Here we connect to the publisher.
if
sys
.
version_info
>
(
2
,
6
)
and
not
hasattr
(
req
,
'timeout'
):
# Workaround mechanize incompatibility with Python
# 2.6. See: LP #280334
req
.
timeout
=
socket
.
_GLOBAL_DEFAULT_TIMEOUT
return
self
.
do_open
(
PublisherConnection
,
req
)
return
self
.
do_open
(
PublisherConnection
,
req
)
...
...
lib/python/Products/PythonScripts/tests/testPythonScript.py
View file @
74ac0363
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
os
,
unittest
,
warnings
import
os
,
sys
,
unittest
,
warnings
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.PythonScripts.PythonScript
import
PythonScript
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
...
@@ -297,13 +297,19 @@ class TestPythonScriptGlobals(PythonScriptTestBase, WarningInterceptor):
...
@@ -297,13 +297,19 @@ class TestPythonScriptGlobals(PythonScriptTestBase, WarningInterceptor):
f
=
self
.
_filePS
(
'class.__name__'
)
f
=
self
.
_filePS
(
'class.__name__'
)
self
.
assertEqual
(
f
(),
(
"'foo'>"
,
"'string'"
))
self
.
assertEqual
(
f
(),
(
"'foo'>"
,
"'string'"
))
def
test_filepath
(
self
):
if
sys
.
version_info
<
(
2
,
6
):
# This test is meant to raise a deprecation warning.
def
test_filepath
(
self
):
# It used to fail mysteriously instead.
# This test is meant to raise a deprecation warning.
self
.
_trap_warning_output
()
# It used to fail mysteriously instead.
f
=
self
.
_filePS
(
'filepath'
)
self
.
_trap_warning_output
()
self
.
assertEqual
(
f
(),
[
0
])
f
=
self
.
_filePS
(
'filepath'
)
self
.
_free_warning_output
()
self
.
assertEqual
(
f
(),
[
0
])
self
.
_free_warning_output
()
else
:
def
test_filepath
(
self
):
# On Python 2.6, this now raises a TypeError.
f
=
self
.
_filePS
(
'filepath'
)
self
.
assertRaises
(
TypeError
,
f
)
class
PythonScriptInterfaceConformanceTests
(
unittest
.
TestCase
):
class
PythonScriptInterfaceConformanceTests
(
unittest
.
TestCase
):
...
...
lib/python/Shared/DC/ZRDB/sqlvar.py
View file @
74ac0363
...
@@ -61,9 +61,10 @@ __version__='$Revision: 1.15 $'[11:-2]
...
@@ -61,9 +61,10 @@ __version__='$Revision: 1.15 $'[11:-2]
from
DocumentTemplate.DT_Util
import
ParseError
,
parse_params
,
name_param
from
DocumentTemplate.DT_Util
import
ParseError
,
parse_params
,
name_param
from
string
import
find
,
split
,
join
,
atoi
,
atof
from
string
import
find
,
split
,
join
,
atoi
,
atof
StringType
=
type
(
''
)
str
=
__builtins__
[
'str'
]
StringType
=
str
str
=
__builtins__
[
'str'
]
class
SQLVar
:
class
SQLVar
:
name
=
'sqlvar'
name
=
'sqlvar'
...
@@ -78,10 +79,10 @@ class SQLVar:
...
@@ -78,10 +79,10 @@ class SQLVar:
self
.
args
=
args
self
.
args
=
args
if
not
args
.
has_key
(
'type'
):
if
not
args
.
has_key
(
'type'
):
raise
ParseError
,
(
'the type attribute is required'
,
'dtvar'
)
raise
ParseError
(
'the type attribute is required'
,
'dtvar'
)
t
=
args
[
'type'
]
t
=
args
[
'type'
]
if
not
valid_type
(
t
):
if
not
valid_type
(
t
):
raise
ParseError
,
(
'invalid type, %s'
%
t
,
'dtvar'
)
raise
ParseError
(
'invalid type, %s'
%
t
,
'dtvar'
)
def
render
(
self
,
md
):
def
render
(
self
,
md
):
name
=
self
.
__name__
name
=
self
.
__name__
...
...
lib/python/ZPublisher/HTTPResponse.py
View file @
74ac0363
...
@@ -217,7 +217,7 @@ class HTTPResponse(BaseResponse):
...
@@ -217,7 +217,7 @@ class HTTPResponse(BaseResponse):
# It has already been determined.
# It has already been determined.
return
return
if
(
isinstance
(
status
,
types
.
ClassType
)
if
(
isinstance
(
status
,
(
type
,
types
.
ClassType
)
)
and
issubclass
(
status
,
Exception
)):
and
issubclass
(
status
,
Exception
)):
status
=
status
.
__name__
status
=
status
.
__name__
...
...
lib/python/ZPublisher/tests/testPublish.py
View file @
74ac0363
...
@@ -29,7 +29,8 @@ class Tracer:
...
@@ -29,7 +29,8 @@ class Tracer:
exception
=
exceptions
[
0
]
exception
=
exceptions
[
0
]
exceptions
.
remove
(
exception
)
exceptions
.
remove
(
exception
)
exceptionShortName
=
exception
.
__name__
# KISS
exceptionShortName
=
exception
.
__name__
# KISS
self
.
append
(
'raising %s from %s'
%
(
exceptionShortName
,
context
))
exceptionShortName
=
exceptionShortName
.
split
(
"'"
)[
0
]
self
.
append
(
'raising %s from %s'
%
(
exceptionShortName
,
context
))
raise
exception
raise
exception
...
...
lib/python/ZServer/HTTPServer.py
View file @
74ac0363
...
@@ -45,7 +45,8 @@ from HTTPResponse import make_response
...
@@ -45,7 +45,8 @@ from HTTPResponse import make_response
from
ZPublisher.HTTPRequest
import
HTTPRequest
from
ZPublisher.HTTPRequest
import
HTTPRequest
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
from
medusa.http_server
import
http_server
,
get_header
,
http_channel
,
VERSION_STRING
from
medusa.http_server
import
http_server
,
get_header
from
medusa.http_server
import
fifo
,
http_channel
,
VERSION_STRING
import
asyncore
import
asyncore
from
medusa
import
counter
,
producers
from
medusa
import
counter
,
producers
from
medusa.test
import
max_sockets
from
medusa.test
import
max_sockets
...
@@ -334,6 +335,18 @@ class zhttp_channel(http_channel):
...
@@ -334,6 +335,18 @@ class zhttp_channel(http_channel):
def
__init__
(
self
,
server
,
conn
,
addr
):
def
__init__
(
self
,
server
,
conn
,
addr
):
http_channel
.
__init__
(
self
,
server
,
conn
,
addr
)
http_channel
.
__init__
(
self
,
server
,
conn
,
addr
)
if
isinstance
(
self
.
producer_fifo
,
fifo
):
self
.
producer_fifo_push
=
self
.
producer_fifo
.
push
self
.
producer_fifo_first
=
self
.
producer_fifo
.
first
self
.
producer_fifo_pop
=
self
.
producer_fifo
.
pop
else
:
self
.
producer_fifo_push
=
self
.
producer_fifo
.
append
def
first
():
return
self
.
producer_fifo
[
0
]
self
.
producer_fifo_first
=
first
def
pop
():
del
self
.
producer_fifo
[
0
]
self
.
producer_fifo_pop
=
pop
requestCloseOnExec
(
conn
)
requestCloseOnExec
(
conn
)
self
.
queue
=
[]
self
.
queue
=
[]
self
.
working
=
0
self
.
working
=
0
...
@@ -345,7 +358,7 @@ class zhttp_channel(http_channel):
...
@@ -345,7 +358,7 @@ class zhttp_channel(http_channel):
# producers by default
# producers by default
if
self
.
closed
:
if
self
.
closed
:
return
return
self
.
producer_fifo
.
push
(
producer
)
self
.
producer_fifo
_
push
(
producer
)
if
send
:
self
.
initiate_send
()
if
send
:
self
.
initiate_send
()
push_with_producer
=
push
push_with_producer
=
push
...
@@ -381,10 +394,10 @@ class zhttp_channel(http_channel):
...
@@ -381,10 +394,10 @@ class zhttp_channel(http_channel):
self
.
current_request
.
channel
=
None
# break circ refs
self
.
current_request
.
channel
=
None
# break circ refs
self
.
current_request
=
None
self
.
current_request
=
None
while
self
.
producer_fifo
:
while
self
.
producer_fifo
:
p
=
self
.
producer_fifo
.
first
()
p
=
self
.
producer_fifo
_
first
()
if
p
is
not
None
and
not
isinstance
(
p
,
basestring
):
if
p
is
not
None
and
not
isinstance
(
p
,
basestring
):
p
.
more
()
# free up resources held by producer
p
.
more
()
# free up resources held by producer
self
.
producer_fifo
.
pop
()
self
.
producer_fifo
_
pop
()
dispatcher
.
close
(
self
)
dispatcher
.
close
(
self
)
def
done
(
self
):
def
done
(
self
):
...
...
lib/python/ZServer/medusa/http_server.py
View file @
74ac0363
...
@@ -528,25 +528,25 @@ class http_channel (asynchat.async_chat):
...
@@ -528,25 +528,25 @@ class http_channel (asynchat.async_chat):
# no handlers, so complain
# no handlers, so complain
r
.
error
(
404
)
r
.
error
(
404
)
def
writable
(
self
):
#
def writable (self):
# this is just the normal async_chat 'writable', here for comparison
#
# this is just the normal async_chat 'writable', here for comparison
return
self
.
ac_out_buffer
or
len
(
self
.
producer_fifo
)
#
return self.ac_out_buffer or len(self.producer_fifo)
def
writable_for_proxy
(
self
):
#
def writable_for_proxy (self):
# this version of writable supports the idea of a 'stalled' producer
#
# this version of writable supports the idea of a 'stalled' producer
# [i.e., it's not ready to produce any output yet] This is needed by
#
# [i.e., it's not ready to produce any output yet] This is needed by
# the proxy, which will be waiting for the magic combination of
#
# the proxy, which will be waiting for the magic combination of
# 1) hostname resolved
#
# 1) hostname resolved
# 2) connection made
#
# 2) connection made
# 3) data available.
#
# 3) data available.
if
self
.
ac_out_buffer
:
#
if self.ac_out_buffer:
return
1
#
return 1
elif
len
(
self
.
producer_fifo
):
#
elif len(self.producer_fifo):
p
=
self
.
producer_fifo
.
first
()
#
p = self.producer_fifo.first()
if
hasattr
(
p
,
'stalled'
):
#
if hasattr (p, 'stalled'):
return
not
p
.
stalled
()
#
return not p.stalled()
else
:
#
else:
return
1
#
return 1
# ===========================================================================
# ===========================================================================
# HTTP Server Object
# HTTP Server Object
...
...
lib/python/Zope2/App/startup.py
View file @
74ac0363
...
@@ -207,8 +207,9 @@ class ZPublisherExceptionHook:
...
@@ -207,8 +207,9 @@ class ZPublisherExceptionHook:
else
:
else
:
error_log_url
=
log
.
raising
((
t
,
v
,
traceback
))
error_log_url
=
log
.
raising
((
t
,
v
,
traceback
))
if
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
'_error_format'
,
''
)
if
(
REQUEST
is
None
or
!=
'text/html'
):
(
getattr
(
REQUEST
.
get
(
'RESPONSE'
,
None
),
'_error_format'
,
''
)
!=
'text/html'
)):
raise
t
,
v
,
traceback
raise
t
,
v
,
traceback
# Lookup a view for the exception and render it, then
# Lookup a view for the exception and render it, then
...
...
lib/python/Zope2/App/tests/testExceptionHook.py
View file @
74ac0363
...
@@ -118,12 +118,20 @@ class ExceptionHookTest(ExceptionHookTestCase):
...
@@ -118,12 +118,20 @@ class ExceptionHookTest(ExceptionHookTestCase):
def
testStringException1
(
self
):
def
testStringException1
(
self
):
def
f
():
def
f
():
raise
'unauthorized'
,
'x'
raise
'unauthorized'
,
'x'
self
.
assertRaises
(
'unauthorized'
,
self
.
call
,
None
,
None
,
f
)
if
sys
.
version_info
<
(
2
,
6
):
self
.
assertRaises
(
'unauthorized'
,
self
.
call
,
None
,
None
,
f
)
else
:
# Raising a string exception causes a TypeError on Python 2.6
self
.
assertRaises
(
TypeError
,
self
.
call
,
None
,
None
,
f
)
def
testStringException2
(
self
):
def
testStringException2
(
self
):
def
f
():
def
f
():
raise
'redirect'
,
'x'
raise
'redirect'
,
'x'
self
.
assertRaises
(
'redirect'
,
self
.
call
,
None
,
None
,
f
)
if
sys
.
version_info
<
(
2
,
6
):
self
.
assertRaises
(
'redirect'
,
self
.
call
,
None
,
None
,
f
)
else
:
# Raising a string exception causes a TypeError on Python 2.6
self
.
assertRaises
(
TypeError
,
self
.
call
,
None
,
None
,
f
)
def
testSystemExit
(
self
):
def
testSystemExit
(
self
):
def
f
():
def
f
():
...
...
lib/python/zExceptions/__init__.py
View file @
74ac0363
...
@@ -18,12 +18,13 @@ application-specific packages.
...
@@ -18,12 +18,13 @@ application-specific packages.
$Id$
$Id$
"""
"""
from
unauthorized
import
Unauthorized
import
warnings
from
zope.interface
import
implements
from
zope.interface
import
implements
from
zope.interface.common.interfaces
import
IException
from
zope.interface.common.interfaces
import
IException
from
zope.publisher.interfaces
import
INotFound
from
zope.publisher.interfaces
import
INotFound
from
zope.security.interfaces
import
IForbidden
from
zope.security.interfaces
import
IForbidden
from
zExceptions.unauthorized
import
Unauthorized
class
BadRequest
(
Exception
):
class
BadRequest
(
Exception
):
implements
(
IException
)
implements
(
IException
)
...
@@ -42,3 +43,29 @@ class MethodNotAllowed(Exception):
...
@@ -42,3 +43,29 @@ class MethodNotAllowed(Exception):
class
Redirect
(
Exception
):
class
Redirect
(
Exception
):
pass
pass
def
upgradeException
(
t
,
v
):
# If a string exception is found, convert it to an equivalent
# exception defined either in builtins or zExceptions. If none of
# that works, tehn convert it to an InternalError and keep the
# original exception name as part of the exception value.
import
zExceptions
if
not
isinstance
(
t
,
basestring
):
return
t
,
v
warnings
.
warn
(
'String exceptions are deprecated starting '
'with Python 2.5 and will be removed in a '
'future release'
,
DeprecationWarning
,
stacklevel
=
2
)
n
=
None
if
__builtins__
.
has_key
(
t
):
n
=
__builtins__
[
t
]
elif
hasattr
(
zExceptions
,
t
):
n
=
getattr
(
zExceptions
,
t
)
if
n
is
not
None
and
issubclass
(
n
,
Exception
):
t
=
n
else
:
v
=
t
,
v
t
=
InternalError
return
t
,
v
utilities/mkzopeinstance.py
View file @
74ac0363
...
@@ -167,10 +167,10 @@ def get_inituser():
...
@@ -167,10 +167,10 @@ def get_inituser():
def
write_inituser
(
fn
,
user
,
password
):
def
write_inituser
(
fn
,
user
,
password
):
import
binascii
import
binascii
import
sha
import
hashlib
fp
=
open
(
fn
,
"w"
)
fp
=
open
(
fn
,
"w"
)
pw
=
binascii
.
b2a_base64
(
sha
.
new
(
password
).
digest
())[:
-
1
]
pw
=
binascii
.
b2a_base64
(
hashlib
.
sha256
(
password
).
digest
())[:
-
1
]
fp
.
write
(
'%s:{SHA}%s
\
n
'
%
(
user
,
pw
))
fp
.
write
(
'%s:{SHA
256
}%s
\
n
'
%
(
user
,
pw
))
fp
.
close
()
fp
.
close
()
os
.
chmod
(
fn
,
0644
)
os
.
chmod
(
fn
,
0644
)
...
...
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