Commit 5ef601d8 authored by 's avatar

*** empty log message ***

parent 29754727
......@@ -16,8 +16,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new
item types.
$Id: SimpleItem.py,v 1.25 1998/11/30 15:27:13 jeffrey Exp $'''
__version__='$Revision: 1.25 $'[11:-2]
$Id: SimpleItem.py,v 1.26 1998/11/30 15:50:25 brian Exp $'''
__version__='$Revision: 1.26 $'[11:-2]
import regex, sys, Globals, App.Management
from DateTime import DateTime
......@@ -44,70 +44,69 @@ class Item(CopySource, App.Management.Tabs):
manage_info =Globals.HTMLFile('App/manage_info')
manage_options=({'icon':'', 'label':'Manage',
'action':'manage_main', 'target':'manage_main',
'action':'manage_main', 'target':'manage_main',
},
{'icon':'', 'label':'Access Control',
'action':'manage_access', 'target':'manage_main',
},
{'icon':'', 'label':'Access Control',
'action':'manage_access', 'target':'manage_main',
},
{'icon':'', 'label':'Undo',
'action':'manage_UndoForm','target':'manage_main',
},
)
},
)
def title_or_id(self):
"""
Utility that returns the title if it is not blank and the id
otherwise.
"""
return self.title or self.id
"""
Utility that returns the title if it is not blank and the id
otherwise.
"""
return self.title or self.id
def title_and_id(self):
"""
Utility that returns the title if it is not blank and the id
otherwise. If the title is not blank, then the id is included
in parens.
"""
t=self.title
return t and ("%s (%s)" % (t,self.id)) or self.id
"""
Utility that returns the title if it is not blank and the id
otherwise. If the title is not blank, then the id is included
in parens.
"""
t=self.title
return t and ("%s (%s)" % (t,self.id)) or self.id
def this(self):
"Handy way to talk to ourselves in document templates."
return self
"Handy way to talk to ourselves in document templates."
return self
def tpURL(self):
"My URL as used by tree tag"
url=self.id
if hasattr(url,'im_func'): url=url()
return url
"My URL as used by tree tag"
url=self.id
if hasattr(url,'im_func'): url=url()
return url
def tpValues(self):
"My sub-objects as used by the tree tag"
return ()
"My sub-objects as used by the tree tag"
return ()
_manage_editedDialog=Globals.HTMLFile('editedDialog', globals())
def manage_editedDialog(self, REQUEST, **args):
return apply(self._manage_editedDialog,(self, REQUEST), args)
return apply(self._manage_editedDialog,(self, REQUEST), args)
def raise_standardErrorMessage(
self, client=None, REQUEST={},
error_type=None, error_value=None, tb=None,
error_tb=None, error_message='',
tagSearch=regex.compile('[a-zA-Z]>').search):
try:
if error_type is None: error_type =sys.exc_info()[0]
if error_value is None: error_value=sys.exc_info()[1]
# allow for a few different traceback options
if tb is None and error_tb is None:
tb=sys.exc_info()[2]
try:
if error_type is None: error_type =sys.exc_info()[0]
if error_value is None: error_value=sys.exc_info()[1]
# allow for a few different traceback options
if tb is None and error_tb is None:
tb=sys.exc_info()[2]
if type(tb) is not type('') and (error_tb is None):
error_tb=pretty_tb(error_type, error_value, tb)
elif type(tb) is type('') and not error_tb:
error_tb=tb
error_tb=pretty_tb(error_type, error_value, tb)
elif type(tb) is type('') and not error_tb:
error_tb=tb
if lower(str(error_type)) in ('redirect',):
raise error_type, error_value, tb
if lower(str(error_type)) in ('redirect',):
raise error_type, error_value, tb
if not error_message:
if type(error_value) is InstanceType:
......@@ -118,25 +117,25 @@ class Item(CopySource, App.Management.Tabs):
and tagSearch(error_value) >= 0):
error_message=error_value
if client is None: client=self
if not REQUEST: REQUEST=self.aq_acquire('REQUEST')
try:
s=getattr(client, 'standard_error_message')
v=HTML.__call__(s, client, REQUEST, error_type=error_type,
error_value=error_value,
error_tb=error_tb,error_traceback=error_tb,
error_message=error_message)
except: v='Sorry, an error occured'
raise error_type, v, tb
finally:
if client is None: client=self
if not REQUEST: REQUEST=self.aq_acquire('REQUEST')
try:
s=getattr(client, 'standard_error_message')
v=HTML.__call__(s, client, REQUEST, error_type=error_type,
error_value=error_value,
error_tb=error_tb,error_traceback=error_tb,
error_message=error_message)
except: v='Sorry, an error occured'
raise error_type, v, tb
finally:
tb=None
def uniqueId(self):
return self._p_oid
return self._p_oid
def aqObjectBind(self, ob):
return ob.__of__(self)
return ob.__of__(self)
def manage(self, URL1):
" "
......@@ -146,46 +145,45 @@ class Item_w__name__(Item):
"""Mixin class to support common name/id functions"""
def title_or_id(self):
"""Utility that returns the title if it is not blank and the id
otherwise."""
return self.title or self.__name__
"""Utility that returns the title if it is not blank and the id
otherwise."""
return self.title or self.__name__
def title_and_id(self):
"""Utility that returns the title if it is not blank and the id
otherwise. If the title is not blank, then the id is included
in parens."""
t=self.title
return t and ("%s (%s)" % (t,self.__name__)) or self.__name__
"""Utility that returns the title if it is not blank and the id
otherwise. If the title is not blank, then the id is included
in parens."""
t=self.title
return t and ("%s (%s)" % (t,self.__name__)) or self.__name__
def _setId(self, id):
self.__name__=id
self.__name__=id
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
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),
' '))
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
......@@ -198,6 +196,9 @@ def pretty_tb(t,v,tb):
##############################################################################
#
# $Log: SimpleItem.py,v $
# Revision 1.26 1998/11/30 15:50:25 brian
# *** empty log message ***
#
# Revision 1.25 1998/11/30 15:27:13 jeffrey
# fixed Syntax error in tpValues
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment