Commit 5ef601d8 authored by 's avatar

*** empty log message ***

parent 29754727
...@@ -16,8 +16,8 @@ Aqueduct database adapters, etc. ...@@ -16,8 +16,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new This module can also be used as a simple template for implementing new
item types. item types.
$Id: SimpleItem.py,v 1.25 1998/11/30 15:27:13 jeffrey Exp $''' $Id: SimpleItem.py,v 1.26 1998/11/30 15:50:25 brian Exp $'''
__version__='$Revision: 1.25 $'[11:-2] __version__='$Revision: 1.26 $'[11:-2]
import regex, sys, Globals, App.Management import regex, sys, Globals, App.Management
from DateTime import DateTime from DateTime import DateTime
...@@ -44,70 +44,69 @@ class Item(CopySource, App.Management.Tabs): ...@@ -44,70 +44,69 @@ class Item(CopySource, App.Management.Tabs):
manage_info =Globals.HTMLFile('App/manage_info') manage_info =Globals.HTMLFile('App/manage_info')
manage_options=({'icon':'', 'label':'Manage', manage_options=({'icon':'', 'label':'Manage',
'action':'manage_main', 'target':'manage_main', 'action':'manage_main', 'target':'manage_main',
}, },
{'icon':'', 'label':'Access Control', {'icon':'', 'label':'Access Control',
'action':'manage_access', 'target':'manage_main', 'action':'manage_access', 'target':'manage_main',
}, },
{'icon':'', 'label':'Undo', {'icon':'', 'label':'Undo',
'action':'manage_UndoForm','target':'manage_main', 'action':'manage_UndoForm','target':'manage_main',
}, },
) )
def title_or_id(self): def title_or_id(self):
""" """
Utility that returns the title if it is not blank and the id Utility that returns the title if it is not blank and the id
otherwise. otherwise.
""" """
return self.title or self.id return self.title or self.id
def title_and_id(self): def title_and_id(self):
""" """
Utility that returns the title if it is not blank and the 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 otherwise. If the title is not blank, then the id is included
in parens. in parens.
""" """
t=self.title t=self.title
return t and ("%s (%s)" % (t,self.id)) or self.id return t and ("%s (%s)" % (t,self.id)) or self.id
def this(self): def this(self):
"Handy way to talk to ourselves in document templates." "Handy way to talk to ourselves in document templates."
return self return self
def tpURL(self): def tpURL(self):
"My URL as used by tree tag" "My URL as used by tree tag"
url=self.id url=self.id
if hasattr(url,'im_func'): url=url() if hasattr(url,'im_func'): url=url()
return url return url
def tpValues(self): def tpValues(self):
"My sub-objects as used by the tree tag" "My sub-objects as used by the tree tag"
return () return ()
_manage_editedDialog=Globals.HTMLFile('editedDialog', globals()) _manage_editedDialog=Globals.HTMLFile('editedDialog', globals())
def manage_editedDialog(self, REQUEST, **args): 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( def raise_standardErrorMessage(
self, client=None, REQUEST={}, self, client=None, REQUEST={},
error_type=None, error_value=None, tb=None, error_type=None, error_value=None, tb=None,
error_tb=None, error_message='', error_tb=None, error_message='',
tagSearch=regex.compile('[a-zA-Z]>').search): tagSearch=regex.compile('[a-zA-Z]>').search):
try: try:
if error_type is None: error_type =sys.exc_info()[0] if error_type is None: error_type =sys.exc_info()[0]
if error_value is None: error_value=sys.exc_info()[1] if error_value is None: error_value=sys.exc_info()[1]
# allow for a few different traceback options # allow for a few different traceback options
if tb is None and error_tb is None: if tb is None and error_tb is None:
tb=sys.exc_info()[2] tb=sys.exc_info()[2]
if type(tb) is not type('') and (error_tb is None): if type(tb) is not type('') and (error_tb is None):
error_tb=pretty_tb(error_type, error_value, tb) error_tb=pretty_tb(error_type, error_value, tb)
elif type(tb) is type('') and not error_tb: elif type(tb) is type('') and not error_tb:
error_tb=tb error_tb=tb
if lower(str(error_type)) in ('redirect',): if lower(str(error_type)) in ('redirect',):
raise error_type, error_value, tb raise error_type, error_value, tb
if not error_message: if not error_message:
if type(error_value) is InstanceType: if type(error_value) is InstanceType:
...@@ -118,25 +117,25 @@ class Item(CopySource, App.Management.Tabs): ...@@ -118,25 +117,25 @@ class Item(CopySource, App.Management.Tabs):
and tagSearch(error_value) >= 0): and tagSearch(error_value) >= 0):
error_message=error_value error_message=error_value
if client is None: client=self if client is None: client=self
if not REQUEST: REQUEST=self.aq_acquire('REQUEST') if not REQUEST: REQUEST=self.aq_acquire('REQUEST')
try: try:
s=getattr(client, 'standard_error_message') s=getattr(client, 'standard_error_message')
v=HTML.__call__(s, client, REQUEST, error_type=error_type, v=HTML.__call__(s, client, REQUEST, error_type=error_type,
error_value=error_value, error_value=error_value,
error_tb=error_tb,error_traceback=error_tb, error_tb=error_tb,error_traceback=error_tb,
error_message=error_message) error_message=error_message)
except: v='Sorry, an error occured' except: v='Sorry, an error occured'
raise error_type, v, tb raise error_type, v, tb
finally: finally:
tb=None tb=None
def uniqueId(self): def uniqueId(self):
return self._p_oid return self._p_oid
def aqObjectBind(self, ob): def aqObjectBind(self, ob):
return ob.__of__(self) return ob.__of__(self)
def manage(self, URL1): def manage(self, URL1):
" " " "
...@@ -146,46 +145,45 @@ class Item_w__name__(Item): ...@@ -146,46 +145,45 @@ class Item_w__name__(Item):
"""Mixin class to support common name/id functions""" """Mixin class to support common name/id functions"""
def title_or_id(self): def title_or_id(self):
"""Utility that returns the title if it is not blank and the id """Utility that returns the title if it is not blank and the id
otherwise.""" otherwise."""
return self.title or self.__name__ return self.title or self.__name__
def title_and_id(self): def title_and_id(self):
"""Utility that returns the title if it is not blank and the 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 otherwise. If the title is not blank, then the id is included
in parens.""" in parens."""
t=self.title t=self.title
return t and ("%s (%s)" % (t,self.__name__)) or self.__name__ return t and ("%s (%s)" % (t,self.__name__)) or self.__name__
def _setId(self, id): def _setId(self, id):
self.__name__=id self.__name__=id
def format_exception(etype,value,tb,limit=None): def format_exception(etype,value,tb,limit=None):
import traceback import traceback
result=['Traceback (innermost last):'] result=['Traceback (innermost last):']
if limit is None: if limit is None:
if hasattr(sys, 'tracebacklimit'): if hasattr(sys, 'tracebacklimit'):
limit = sys.tracebacklimit limit = sys.tracebacklimit
n = 0 n = 0
while tb is not None and (limit is None or n < limit): while tb is not None and (limit is None or n < limit):
f = tb.tb_frame f = tb.tb_frame
lineno = tb.tb_lineno lineno = tb.tb_lineno
co = f.f_code co = f.f_code
filename = co.co_filename filename = co.co_filename
name = co.co_name name = co.co_name
locals=f.f_locals locals=f.f_locals
result.append(' File %s, line %d, in %s' result.append(' File %s, line %d, in %s'
% (filename,lineno,name)) % (filename,lineno,name))
try: result.append(' (Object: %s)' % try: result.append(' (Object: %s)' %
locals[co.co_varnames[0]].__name__) locals[co.co_varnames[0]].__name__)
except: pass except: pass
try: result.append(' (Info: %s)' % try: result.append(' (Info: %s)' %
str(locals['__traceback_info__'])) str(locals['__traceback_info__']))
except: pass except: pass
tb = tb.tb_next tb = tb.tb_next
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 # sys.exc_type,sys.exc_value,sys.exc_traceback=etype,value,tb
return result return result
...@@ -198,6 +196,9 @@ def pretty_tb(t,v,tb): ...@@ -198,6 +196,9 @@ def pretty_tb(t,v,tb):
############################################################################## ##############################################################################
# #
# $Log: SimpleItem.py,v $ # $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 # Revision 1.25 1998/11/30 15:27:13 jeffrey
# fixed Syntax error in tpValues # 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