handing errors when no tickets in db, thanks Niphold
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 1.99.4 (2012-02-28 15:13:05) stable
|
||||
Version 1.99.4 (2012-02-28 15:39:53) stable
|
||||
|
||||
@@ -1061,7 +1061,10 @@ def errors():
|
||||
app = get_app()
|
||||
|
||||
method = request.args(1) or 'new'
|
||||
|
||||
db_ready = {}
|
||||
db_ready['status'] = get_ticket_storage(app)
|
||||
db_ready['errmessage'] = "No ticket_storage.txt found under /private folder"
|
||||
db_ready['errlink'] = "http://web2py.com/books/default/chapter/29/13#Collecting-tickets"
|
||||
|
||||
if method == 'new':
|
||||
errors_path = apath('%s/errors' % app, r=request)
|
||||
@@ -1104,7 +1107,7 @@ def errors():
|
||||
decorated = [(x['count'], x) for x in hash2error.values()]
|
||||
decorated.sort(key=operator.itemgetter(0), reverse=True)
|
||||
|
||||
return dict(errors = [x[1] for x in decorated], app=app, method=method)
|
||||
return dict(errors = [x[1] for x in decorated], app=app, method=method, db_ready=db_ready)
|
||||
|
||||
elif method == 'dbnew':
|
||||
errors_path = apath('%s/errors' % app, r=request)
|
||||
@@ -1169,16 +1172,16 @@ def errors():
|
||||
key=func,
|
||||
reverse=True)
|
||||
|
||||
return dict(app=app, tickets=tickets, method=method)
|
||||
return dict(app=app, tickets=tickets, method=method, db_ready=db_ready)
|
||||
|
||||
def get_ticket_storage(app):
|
||||
private_folder = apath('%s/private' % app, r=request)
|
||||
ticket_file = os.path.join(private_folder, 'ticket_storage.txt')
|
||||
if os.path.exists(ticket__file):
|
||||
if os.path.exists(ticket_file):
|
||||
db_string = open(ticket_file).read()
|
||||
db_string = db_string.strip().replace('\r','').replace('\n','')
|
||||
else:
|
||||
raise Exception, "No ticket_storage.txt found in /private folder"
|
||||
return False
|
||||
tickets_table = 'web2py_ticket'
|
||||
tablename = tickets_table + '_' + app
|
||||
db_path = apath('%s/databases' % app, r=request)
|
||||
|
||||
@@ -19,6 +19,9 @@ table.sortable thead {
|
||||
tr.error_ticket:hover {
|
||||
background-color: #eee;
|
||||
}
|
||||
a.unavailable {
|
||||
color: #ff0000;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script language="JavaScript">
|
||||
@@ -36,7 +39,13 @@ tr.error_ticket:hover {
|
||||
}
|
||||
jQuery(document).ready(function() { jQuery('.traceback').hide(); });
|
||||
</script>
|
||||
|
||||
{{if db_ready['status'] == False:
|
||||
switchurl = db_ready['errmessage']
|
||||
switchbutton = XML("""<a data-role="button" data-inline="true" data-inline="true" href="%(href)s" title="%(title)s" class="unavailable"><span>switch to : db</span></a>""" % dict(href=switchurl, title=db_ready['errmessage']))
|
||||
else:
|
||||
switchurl = URL(args=[app, 'dbnew'])
|
||||
switchbutton = XML("""<a data-role="button" data-inline="true" data-inline="true" href="%s"><span>switch to : db</span></a>""" % (switchurl))
|
||||
pass}}
|
||||
<h2>{{=T('Error logs for "%(app)s"',dict(app=app))}}</h2>
|
||||
|
||||
<div>
|
||||
@@ -59,7 +68,7 @@ tr.error_ticket:hover {
|
||||
<a data-role="button" data-inline="true" href="{{=URL(args=[app, 'dbold'])}}"><span>lists by ticket</span></a>
|
||||
{{else:}}
|
||||
source : filesystem
|
||||
<a data-role="button" data-inline="true" data-inline="true" href="{{=URL(args=[app, 'dbnew'])}}"><span>switch to : db</span></a>
|
||||
{{=switchbutton}}
|
||||
<a data-role="button" data-inline="true" href="{{=URL(args=[app, 'old'])}}"><span>lists by ticket</span></a>
|
||||
{{pass}}
|
||||
</p>
|
||||
@@ -103,7 +112,7 @@ tr.error_ticket:hover {
|
||||
<a data-role="button" data-inline="true" href="{{=URL(args=[app, 'dbnew'])}}"><span>lists by exception</span></a>
|
||||
{{else:}}
|
||||
source : filesystem
|
||||
<a data-role="button" data-inline="true" href="{{=URL(args=[app, 'dbold'])}}"><span>switch to : db</span></a>
|
||||
{{=switchbutton}}
|
||||
<a data-role="button" data-inline="true" href="{{=URL(args=[app, 'new'])}}"><span>lists by exception</span></a>
|
||||
{{pass}}
|
||||
</p>
|
||||
|
||||
@@ -19,6 +19,9 @@ table.sortable thead {
|
||||
tr.error_ticket:hover {
|
||||
background-color: #eee;
|
||||
}
|
||||
.controls a.button.unavailable {
|
||||
color: #ff0000;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script language="JavaScript">
|
||||
@@ -36,6 +39,11 @@ tr.error_ticket:hover {
|
||||
}
|
||||
jQuery(document).ready(function() { jQuery('.traceback').hide(); });
|
||||
</script>
|
||||
{{if db_ready['status'] == False:
|
||||
switchbutton = A(SPAN("switch to : db"), _href=db_ready['errlink'], _class="button unavailable", _title="%s" % (db_ready['errmessage']))
|
||||
else:
|
||||
switchbutton = A(SPAN("switch to : db"), _href=URL(args=[app, 'dbnew']), _class="button")
|
||||
pass}}
|
||||
|
||||
<h2>{{=T('Error logs for "%(app)s"',dict(app=app))}}</h2>
|
||||
|
||||
@@ -57,7 +65,7 @@ tr.error_ticket:hover {
|
||||
<a class="button" href="{{=URL(args=[app, 'dbold'])}}"><span>lists by ticket</span></a>
|
||||
{{else:}}
|
||||
source : filesystem
|
||||
<a class="button" href="{{=URL(args=[app, 'dbnew'])}}"><span>switch to : db</span></a>
|
||||
{{=switchbutton}}
|
||||
<a class="button" href="{{=URL(args=[app, 'old'])}}"><span>lists by ticket</span></a>
|
||||
{{pass}}
|
||||
</p>
|
||||
@@ -101,7 +109,7 @@ tr.error_ticket:hover {
|
||||
<a class="button" href="{{=URL(args=[app, 'dbnew'])}}"><span>lists by exception</span></a>
|
||||
{{else:}}
|
||||
source : filesystem
|
||||
<a class="button" href="{{=URL(args=[app, 'dbold'])}}"><span>switch to : db</span></a>
|
||||
{{=switchbutton}}
|
||||
<a class="button" href="{{=URL(args=[app, 'new'])}}"><span>lists by exception</span></a>
|
||||
{{pass}}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user