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.
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
from
httplib
import
HTTP
...
...
@@ -185,8 +185,8 @@ class Function:
ec
,
em
,
headers
=
h
.
getreply
()
response
=
h
.
getfile
().
read
()
except
:
raise
NotAvailable
,
\
RemoteException
(
NotAvailable
,
sys
.
exc_value
,
self
.
url
,
query
)
raise
NotAvailable
,
RemoteException
(
NotAvailable
,
sys
.
exc_value
,
self
.
url
,
query
)
if
ec
==
200
:
return
(
headers
,
response
)
self
.
handleError
(
query
,
ec
,
em
,
headers
,
response
)
...
...
@@ -588,7 +588,6 @@ def main():
kw[name]=v
except:
# print "%s: %s
\
n
%s" % (sys.exc_type, sys.exc_value, usage)
print usage
sys.exit(1)
...
...
lib/python/ZPublisher/Publish.py
View file @
c30829ba
...
...
@@ -478,11 +478,11 @@ Publishing a module using CGI
containing the module to be published) to the module name in the
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
from
string
import
*
...
...
@@ -646,7 +646,7 @@ class ModulePublisher:
raise
'NotFound'
,
self
.
html
(
"Resource not found"
,
"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,
# why reveal that it exists?
...
...
@@ -953,6 +953,7 @@ def get_module_info(module_name, modules={},
if
module_name
[
-
4
:]
==
'.cgi'
:
module_name
=
module_name
[:
-
4
]
acquire
()
tb
=
None
try
:
try
:
module
=
__import__
(
module_name
)
...
...
@@ -1015,9 +1016,13 @@ def get_module_info(module_name, modules={},
return
info
except
:
raise
ImportError
,
(
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
)
finally
:
release
()
if
hasattr
(
sys
,
'exc_info'
):
t
,
v
,
tb
=
sys
.
exc_info
()
else
:
t
,
v
,
tb
=
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
v
=
str
(
v
)
raise
ImportError
,
(
t
,
v
),
tb
finally
:
tb
=
None
release
()
def
str_field
(
v
):
if
type
(
v
)
is
ListType
:
...
...
@@ -1448,14 +1453,15 @@ def publish_module(module_name,
pass
response = publisher.publish(module_name,after_list,
debug=debug)
except SystemExit:
must_die=1
except SystemExit, v:
if hasattr(sys, 'exc_info'): must_die=sys.exc_info()
else: must_die = SystemExit, v, sys.exc_traceback
response.exception(must_die)
except ImportError, v:
if type(v)
==TupleType and len(v)==3:
sys.exc_type, sys.exc_value, sys.exc_traceback = v
must_die=1
response.exception(
must_die
)
if type(v)
is tyoe(()) and len(v)==3: must_die=v
elif hasattr(sys, 'exc_info'): must_die=sys.exc_info()
else: must_die = SystemExit, v, sys.exc_traceback
response.exception(
1, v
)
except:
response.exception()
status=response.getStatus()
...
...
@@ -1469,8 +1475,7 @@ def publish_module(module_name,
finally:
if request is not None: request.other={}
if must_die:
raise sys.exc_type, sys.exc_value, sys.exc_traceback
if must_die: raise must_die[0], must_die[1], must_die[2]
sys.exc_type, sys.exc_value, sys.exc_traceback = None, None, None
return status
lib/python/ZPublisher/Response.py
View file @
c30829ba
'''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.
# All rights reserved.
...
...
@@ -51,7 +51,7 @@ $Id: Response.py,v 1.36 1998/09/03 14:50:16 jim Exp $'''
#
# (540) 371-6909
#
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
7
$'
[
11
:
-
2
]
import
string
,
types
,
sys
,
regex
from
string
import
find
,
rfind
,
lower
,
upper
,
strip
,
split
,
join
,
translate
...
...
@@ -412,7 +412,6 @@ class Response:
n = n+1
result.append(join(traceback.format_exception_only(etype, value),
' '))
sys.exc_type,sys.exc_value,sys.exc_traceback=etype,value,tb
return result
def _traceback(self,t,v,tb):
...
...
@@ -429,13 +428,16 @@ class Response:
headers['location']=location
return location
def exception(self, fatal=0,
def exception(self, fatal=0,
info=None,
absuri_match=regex.compile(
"
[
a
-
zA
-
Z0
-
9
+
.
-
]
+
:[
^
\
0
-
\
"
\
#<>]+
\
(#[^
\
0
-
\
"
\
#<>]*
\
)?"
).
match
,
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
# Abort running transaction, if any:
...
...
lib/python/ZPublisher/Test.py
View file @
c30829ba
...
...
@@ -130,9 +130,9 @@ Examples
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
repeat_count
=
100
...
...
@@ -229,6 +229,11 @@ def publish_module_pm(module_name,
except
:
pass
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
):
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):
self
.
do_c
(
''
)
self
.
done_ob
=
1
import
codehack
db
=
Pdb
()
def
fbreak
(
db
,
meth
,
codehack
=
codehack
):
def
fbreak
(
db
,
meth
):
try
:
meth
=
meth
.
im_func
except
AttributeError
:
pass
code
=
meth
.
func_code
lineno
=
codehack
.
getlineno
(
code
)
lineno
=
getlineno
(
code
)
filename
=
code
.
co_filename
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