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
c30829ba
Commit
c30829ba
authored
Sep 03, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed error handling problems
parent
00a0ec19
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
28 deletions
+38
-28
lib/python/ZPublisher/Client.py
lib/python/ZPublisher/Client.py
+3
-4
lib/python/ZPublisher/Publish.py
lib/python/ZPublisher/Publish.py
+19
-14
lib/python/ZPublisher/Response.py
lib/python/ZPublisher/Response.py
+7
-5
lib/python/ZPublisher/Test.py
lib/python/ZPublisher/Test.py
+9
-5
No files found.
lib/python/ZPublisher/Client.py
View file @
c30829ba
...
@@ -72,7 +72,7 @@ that allows one to simply make a single web request.
...
@@ -72,7 +72,7 @@ that allows one to simply make a single web request.
The module also provides a command-line interface for calling objects.
The module also provides a command-line interface for calling objects.
"""
"""
__version__
=
'$Revision: 1.2
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
5
$'
[
11
:
-
2
]
import
sys
,
regex
,
socket
,
mimetools
import
sys
,
regex
,
socket
,
mimetools
from
httplib
import
HTTP
from
httplib
import
HTTP
...
@@ -185,8 +185,8 @@ class Function:
...
@@ -185,8 +185,8 @@ class Function:
ec
,
em
,
headers
=
h
.
getreply
()
ec
,
em
,
headers
=
h
.
getreply
()
response
=
h
.
getfile
().
read
()
response
=
h
.
getfile
().
read
()
except
:
except
:
raise
NotAvailable
,
\
raise
NotAvailable
,
RemoteException
(
RemoteException
(
NotAvailable
,
sys
.
exc_value
,
self
.
url
,
query
)
NotAvailable
,
sys
.
exc_value
,
self
.
url
,
query
)
if
ec
==
200
:
return
(
headers
,
response
)
if
ec
==
200
:
return
(
headers
,
response
)
self
.
handleError
(
query
,
ec
,
em
,
headers
,
response
)
self
.
handleError
(
query
,
ec
,
em
,
headers
,
response
)
...
@@ -588,7 +588,6 @@ def main():
...
@@ -588,7 +588,6 @@ def main():
kw[name]=v
kw[name]=v
except:
except:
# print "%s: %s
\
n
%s" % (sys.exc_type, sys.exc_value, usage)
print usage
print usage
sys.exit(1)
sys.exit(1)
...
...
lib/python/ZPublisher/Publish.py
View file @
c30829ba
...
@@ -478,11 +478,11 @@ Publishing a module using CGI
...
@@ -478,11 +478,11 @@ Publishing a module using CGI
containing the module to be published) to the module name in the
containing the module to be published) to the module name in the
cgi-bin directory.
cgi-bin directory.
$Id: Publish.py,v 1.9
2 1998/09/03 14:50:17
jim Exp $"""
$Id: Publish.py,v 1.9
3 1998/09/03 16:59:11
jim Exp $"""
#'
#'
#
#
##########################################################################
##########################################################################
__version__
=
'$Revision: 1.9
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.9
3
$'
[
11
:
-
2
]
import
sys
,
os
,
string
,
cgi
,
regex
import
sys
,
os
,
string
,
cgi
,
regex
from
string
import
*
from
string
import
*
...
@@ -646,7 +646,7 @@ class ModulePublisher:
...
@@ -646,7 +646,7 @@ class ModulePublisher:
raise
'NotFound'
,
self
.
html
(
raise
'NotFound'
,
self
.
html
(
"Resource not found"
,
"Resource not found"
,
"Sorry, the requested document does not exist.<p>"
"Sorry, the requested document does not exist.<p>"
"
\
n
<!--
\
n
%s
\
n
-->"
%
entry
)
,
sys
.
exc_traceback
"
\
n
<!--
\
n
%s
\
n
-->"
%
entry
)
forbiddenError
=
notFoundError
# If a resource is forbidden,
forbiddenError
=
notFoundError
# If a resource is forbidden,
# why reveal that it exists?
# why reveal that it exists?
...
@@ -953,6 +953,7 @@ def get_module_info(module_name, modules={},
...
@@ -953,6 +953,7 @@ def get_module_info(module_name, modules={},
if
module_name
[
-
4
:]
==
'.cgi'
:
module_name
=
module_name
[:
-
4
]
if
module_name
[
-
4
:]
==
'.cgi'
:
module_name
=
module_name
[:
-
4
]
acquire
()
acquire
()
tb
=
None
try
:
try
:
try
:
try
:
module
=
__import__
(
module_name
)
module
=
__import__
(
module_name
)
...
@@ -1015,9 +1016,13 @@ def get_module_info(module_name, modules={},
...
@@ -1015,9 +1016,13 @@ def get_module_info(module_name, modules={},
return
info
return
info
except
:
except
:
raise
ImportError
,
(
if
hasattr
(
sys
,
'exc_info'
):
t
,
v
,
tb
=
sys
.
exc_info
()
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
)
else
:
t
,
v
,
tb
=
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
finally
:
release
()
v
=
str
(
v
)
raise
ImportError
,
(
t
,
v
),
tb
finally
:
tb
=
None
release
()
def
str_field
(
v
):
def
str_field
(
v
):
if
type
(
v
)
is
ListType
:
if
type
(
v
)
is
ListType
:
...
@@ -1448,14 +1453,15 @@ def publish_module(module_name,
...
@@ -1448,14 +1453,15 @@ def publish_module(module_name,
pass
pass
response = publisher.publish(module_name,after_list,
response = publisher.publish(module_name,after_list,
debug=debug)
debug=debug)
except SystemExit:
except SystemExit, v:
must_die=1
if hasattr(sys, 'exc_info'): must_die=sys.exc_info()
else: must_die = SystemExit, v, sys.exc_traceback
response.exception(must_die)
response.exception(must_die)
except ImportError, v:
except ImportError, v:
if type(v)
==TupleType and len(v)==3:
if type(v)
is tyoe(()) and len(v)==3: must_die=v
sys.exc_type, sys.exc_value, sys.exc_traceback = v
elif hasattr(sys, 'exc_info'): must_die=sys.exc_info()
must_die=1
else: must_die = SystemExit, v, sys.exc_traceback
response.exception(
must_die
)
response.exception(
1, v
)
except:
except:
response.exception()
response.exception()
status=response.getStatus()
status=response.getStatus()
...
@@ -1469,8 +1475,7 @@ def publish_module(module_name,
...
@@ -1469,8 +1475,7 @@ def publish_module(module_name,
finally:
finally:
if request is not None: request.other={}
if request is not None: request.other={}
if must_die:
if must_die: raise must_die[0], must_die[1], must_die[2]
raise sys.exc_type, sys.exc_value, sys.exc_traceback
sys.exc_type, sys.exc_value, sys.exc_traceback = None, None, None
sys.exc_type, sys.exc_value, sys.exc_traceback = None, None, None
return status
return status
lib/python/ZPublisher/Response.py
View file @
c30829ba
'''CGI Response Output formatter
'''CGI Response Output formatter
$Id: Response.py,v 1.3
6 1998/09/03 14:50:16
jim Exp $'''
$Id: Response.py,v 1.3
7 1998/09/03 16:59:10
jim Exp $'''
#
#
# Copyright (c) 1998, Digital Creations, Fredericksburg, VA, USA.
# Copyright (c) 1998, Digital Creations, Fredericksburg, VA, USA.
# All rights reserved.
# All rights reserved.
...
@@ -51,7 +51,7 @@ $Id: Response.py,v 1.36 1998/09/03 14:50:16 jim Exp $'''
...
@@ -51,7 +51,7 @@ $Id: Response.py,v 1.36 1998/09/03 14:50:16 jim Exp $'''
#
#
# (540) 371-6909
# (540) 371-6909
#
#
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
7
$'
[
11
:
-
2
]
import
string
,
types
,
sys
,
regex
import
string
,
types
,
sys
,
regex
from
string
import
find
,
rfind
,
lower
,
upper
,
strip
,
split
,
join
,
translate
from
string
import
find
,
rfind
,
lower
,
upper
,
strip
,
split
,
join
,
translate
...
@@ -412,7 +412,6 @@ class Response:
...
@@ -412,7 +412,6 @@ class Response:
n = n+1
n = n+1
result.append(join(traceback.format_exception_only(etype, value),
result.append(join(traceback.format_exception_only(etype, value),
' '))
' '))
sys.exc_type,sys.exc_value,sys.exc_traceback=etype,value,tb
return result
return result
def _traceback(self,t,v,tb):
def _traceback(self,t,v,tb):
...
@@ -429,13 +428,16 @@ class Response:
...
@@ -429,13 +428,16 @@ class Response:
headers['location']=location
headers['location']=location
return location
return location
def exception(self, fatal=0,
def exception(self, fatal=0,
info=None,
absuri_match=regex.compile(
absuri_match=regex.compile(
"
[
a
-
zA
-
Z0
-
9
+
.
-
]
+
:[
^
\
0
-
\
"
\
#<>]+
\
(#[^
\
0
-
\
"
\
#<>]*
\
)?"
"
[
a
-
zA
-
Z0
-
9
+
.
-
]
+
:[
^
\
0
-
\
"
\
#<>]+
\
(#[^
\
0
-
\
"
\
#<>]*
\
)?"
).
match
,
).
match
,
tag_search
=
regex
.
compile
(
'[a-zA-Z]>'
).
search
,
tag_search
=
regex
.
compile
(
'[a-zA-Z]>'
).
search
,
):
):
t
,
v
,
tb
=
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
if
type
(
info
)
is
type
(())
and
len
(
info
)
==
3
:
t
,
v
,
tb
=
info
elif
hasattr
(
sys
,
'exc_info'
):
t
,
v
,
tb
=
sys
.
exc_info
()
else
:
t
,
v
,
tb
=
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
stb
=
tb
stb
=
tb
# Abort running transaction, if any:
# Abort running transaction, if any:
...
...
lib/python/ZPublisher/Test.py
View file @
c30829ba
...
@@ -130,9 +130,9 @@ Examples
...
@@ -130,9 +130,9 @@ Examples
s
s
$Id: Test.py,v 1.1
8 1998/09/03 14:50:17
jim Exp $
$Id: Test.py,v 1.1
9 1998/09/03 16:59:11
jim Exp $
'''
'''
__version__
=
'$Revision: 1.1
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
9
$'
[
11
:
-
2
]
import
sys
,
traceback
,
profile
,
os
import
sys
,
traceback
,
profile
,
os
repeat_count
=
100
repeat_count
=
100
...
@@ -229,6 +229,11 @@ def publish_module_pm(module_name,
...
@@ -229,6 +229,11 @@ def publish_module_pm(module_name,
except
:
pass
except
:
pass
if
after_list
[
0
]
is
not
None
:
after_list
[
0
]()
if
after_list
[
0
]
is
not
None
:
after_list
[
0
]()
try
:
from
codehack
import
getlineno
except
:
def
getlineno
(
code
):
return
code
.
co_firstlineno
def
publish
(
script
,
path_info
,
u
=
None
,
p
=
None
,
d
=
None
,
t
=
None
,
e
=
{},
s
=
None
,
pm
=
0
):
def
publish
(
script
,
path_info
,
u
=
None
,
p
=
None
,
d
=
None
,
t
=
None
,
e
=
{},
s
=
None
,
pm
=
0
):
import
sys
,
os
,
getopt
,
string
import
sys
,
os
,
getopt
,
string
...
@@ -307,14 +312,13 @@ def publish(script,path_info,u=None,p=None,d=None,t=None,e={},s=None,pm=0):
...
@@ -307,14 +312,13 @@ def publish(script,path_info,u=None,p=None,d=None,t=None,e={},s=None,pm=0):
self
.
do_c
(
''
)
self
.
do_c
(
''
)
self
.
done_ob
=
1
self
.
done_ob
=
1
import
codehack
db
=
Pdb
()
db
=
Pdb
()
def
fbreak
(
db
,
meth
,
codehack
=
codehack
):
def
fbreak
(
db
,
meth
):
try
:
meth
=
meth
.
im_func
try
:
meth
=
meth
.
im_func
except
AttributeError
:
pass
except
AttributeError
:
pass
code
=
meth
.
func_code
code
=
meth
.
func_code
lineno
=
codehack
.
getlineno
(
code
)
lineno
=
getlineno
(
code
)
filename
=
code
.
co_filename
filename
=
code
.
co_filename
db
.
set_break
(
filename
,
lineno
)
db
.
set_break
(
filename
,
lineno
)
...
...
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