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
e1717745
Commit
e1717745
authored
Mar 23, 1998
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added custom error message support
parent
69f09184
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
6 deletions
+84
-6
lib/python/OFS/Application.py
lib/python/OFS/Application.py
+19
-2
lib/python/OFS/Document.py
lib/python/OFS/Document.py
+65
-4
No files found.
lib/python/OFS/Application.py
View file @
e1717745
...
...
@@ -11,8 +11,8 @@
__doc__
=
'''Application support
$Id: Application.py,v 1.5
5 1998/03/09 19:37:09 jim
Exp $'''
__version__
=
'$Revision: 1.5
5
$'
[
11
:
-
2
]
$Id: Application.py,v 1.5
6 1998/03/23 15:01:22 jeffrey
Exp $'''
__version__
=
'$Revision: 1.5
6
$'
[
11
:
-
2
]
import
Globals
,
Folder
,
os
,
regex
,
sys
...
...
@@ -24,6 +24,11 @@ from App.ApplicationManager import ApplicationManager
from
Persistence
import
Persistent
from
ImageFile
import
ImageFile
_standard_error_msg
=
'''
\
<!--#var standard_html_header-->
<H2>Error: <!--#var error_type-->, <!--#var error_value--></H2>
<!-- <!--#var error_tb--> -->
<!--#var standard_html_footer-->'''
class
Application
(
Folder
.
Folder
):
title
=
'Principia'
...
...
@@ -74,6 +79,7 @@ class Application(Folder.Folder):
_reserved_names
=
(
'standard_html_header'
,
'standard_html_footer'
,
#'standard_error_message',
'acl_users'
,
'Control_Panel'
)
...
...
@@ -94,6 +100,9 @@ class Application(Folder.Folder):
self
.
manage_addDocument
(
'standard_html_footer'
,
'Standard Html Footer'
,
'</BODY></HTML>'
)
self
.
manage_addDocument
(
'standard_error_message'
,
'Standard Error Message'
,
_standard_error_msg
)
def
id
(
self
):
...
...
@@ -178,6 +187,11 @@ def open_bobobase():
cpl
.
_init
()
app
.
_setObject
(
'Control_Panel'
,
cpl
)
get_transaction
().
commit
()
if
not
hasattr
(
app
,
'standard_error_message'
):
app
.
manage_addDocument
(
'standard_error_message'
,
'Standard Error Message'
,
_standard_error_msg
)
get_transaction
().
commit
()
return
Bobobase
...
...
@@ -364,6 +378,9 @@ class Misc_:
##############################################################################
#
# $Log: Application.py,v $
# Revision 1.56 1998/03/23 15:01:22 jeffrey
# Added custom error message support
#
# Revision 1.55 1998/03/09 19:37:09 jim
# Check for true need_license before doing license check.
#
...
...
lib/python/OFS/Document.py
View file @
e1717745
"""Document object"""
__version__
=
'$Revision: 1.4
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
6
$'
[
11
:
-
2
]
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
,
lower
from
AccessControl.Role
import
RoleManager
from
SimpleItem
import
Item_w__name__
from
Acquisition
import
Explicit
import
regex
,
Globals
import
regex
,
Globals
,
sys
class
Document
(
HTML
,
Explicit
,
RoleManager
,
Item_w__name__
):
...
...
@@ -71,7 +71,34 @@ class Document(HTML, Explicit, RoleManager, Item_w__name__):
""" """
kw
[
'document_id'
]
=
self
.
id
kw
[
'document_title'
]
=
self
.
title
r
=
apply
(
HTML
.
__call__
,
(
self
,
client
,
REQUEST
),
kw
)
try
:
r
=
apply
(
HTML
.
__call__
,
(
self
,
client
,
REQUEST
),
kw
)
except
:
if
self
.
id
()
==
'standard_error_message'
:
raise
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
error_type
=
sys
.
exc_type
error_value
=
sys
.
exc_value
if
lower
(
error_type
)
in
(
'redirect'
,):
raise
error_type
,
error_value
,
sys
.
exc_traceback
if
regex
.
search
(
'[a-zA-Z]>'
,
error_value
)
>
0
:
error_message
=
error_value
else
:
error_message
=
''
tb
=
sys
.
exc_traceback
error_tb
=
pretty_tb
(
error_type
,
error_value
,
tb
)
if
client
is
not
None
:
c
=
client
else
:
c
=
self
.
aq_parent
try
:
s
=
getattr
(
c
,
'standard_error_message'
)
v
=
HTML
.
__call__
(
s
,
c
,
REQUEST
,
error_type
=
error_type
,
error_value
=
error_value
,
error_tb
=
error_tb
,
error_message
=
error_message
)
except
:
v
=
'Sorry, an error occured'
sys
.
exc_traceback
=
tb
tb
=
None
raise
error_type
,
v
,
sys
.
exc_traceback
if
RESPONSE
is
None
:
return
r
return
decapitate
(
r
,
RESPONSE
)
...
...
@@ -270,3 +297,37 @@ def decapitate(html, RESPONSE=None,
return html
def format_exception(etype,value,tb,limit=None):
import traceback
result=['
Traceback
(
innermost
last
):
']
if limit is None:
if hasattr(sys, '
tracebacklimit
'):
limit = sys.tracebacklimit
n = 0
while tb is not None and (limit is None or n < limit):
f = tb.tb_frame
lineno = tb.tb_lineno
co = f.f_code
filename = co.co_filename
name = co.co_name
locals=f.f_locals
result.append('
File
%
s
,
line
%
d
,
in
%
s
'
% (filename,lineno,name))
try: result.append('
(
Object
:
%
s
)
' %
locals[co.co_varnames[0]].__name__)
except: pass
try: result.append('
(
Info
:
%
s
)
' %
str(locals['
__traceback_info__
']))
except: pass
tb = tb.tb_next
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 pretty_tb(t,v,tb):
tb=format_exception(t,v,tb,200)
tb=join(tb,'
\
n
')
return tb
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