I can understand not making the admin interface
accessible over an insecure connection, but because
the ticket notification is tied to the admin system,
here's what I have to do:
- user reports an error, sends me the ticket
- I fire up another copy of web2py on a different port
- run a proxy: ssh -L 8001:127.0.0.1:8001 m...@192.168.2.56
- get the ticket info
- shut everything down
That's a lot of work just to get a traceback when attempting
rapid development. There are settings where read-only access
to the ticket info is justified, even if you don't want to
grant users full admin access.
--
Jeff Bauer
Rubicon, Inc.
I encourage people to build one and I will be happy to post it.
Massimo
web2py/applications/myapp/errors
Jeff Bauer
Rubicon, Inc.
note that because this is a copy of code from the admin interface it's
not best practice, but i was in a hurry. Also keep in mind that this
breaks the security of the ticket system, which is why it is set up
the way it is in the first place, so use with care.
in default.py in my application i added:
from applications.rockriver.modules.parse_xml import *
from gluon.restricted import RestrictedError
import os
####################
# ticket stuff
####################
def make_link(path):
""" Create a link from a path """
tryFile = path.replace('\\', '/')
if os.path.isabs(tryFile) and os.path.isfile(tryFile):
(folder, filename) = os.path.split(tryFile)
(base, ext) = os.path.splitext(filename)
app = request.args[0]
editable = {'controllers': '.py', 'models': '.py', 'views':
'.html'}
for key in editable.keys():
check_extension = folder.endswith("%s/%s" % (app,key))
if ext.lower() == editable[key] and check_extension:
return A('"' + tryFile + '"',
_href=URL(r=request,
f='edit/%s/%s/%s' % (app, key, filename))).xml
()
return ''
def make_links(traceback):
""" Make links using the given traceback """
lwords = traceback.split('"')
# Making the short circuit compatible with <= python2.4
result = (len(lwords) != 0) and lwords[0] or ''
i = 1
while i < len(lwords):
link = make_link(lwords[i])
if link == '':
result += '"' + lwords[i]
else:
result += link
if i + 1 < len(lwords):
result += lwords[i + 1]
i = i + 1
i = i + 1
return result
class TRACEBACK(object):
""" Generate the traceback """
def __init__(self, text):
""" TRACEBACK constructor """
self.s = make_links(CODE(text).xml())
def xml(self):
""" Returns the xml """
return self.s
@auth.requires_login()
def ticket():
""" Ticket handler """
if len(request.args) != 2:
session.flash = T('invalid ticket')
redirect(URL(r=request, f='site'))
app = request.args[0]
ticket = request.args[1]
e = RestrictedError()
e.load(request, app, ticket)
return dict(app=app,
ticket=ticket,
traceback=TRACEBACK(e.traceback),
code=e.code,
layer=e.layer)
#############
in routes.py i added an error message to make the link point back to
my app (note that i already have a route that removes the app name
from the URL):
error_message = '<html><body><h1>Invalid request</h1></body></html>'
error_message_ticket = '<html><body><h1>Internal error</h1>Ticket
issued: <a href="/default/ticket/%(ticket)s" target="_blank">%(ticket)
s</a></body></html>'
I've added a new issue to google code and linked it
to this thread.
http://code.google.com/p/web2py/issues/detail?id=69
Jeff Bauer
Rubicon, Inc.
+1 this has been really painful for us for the Haiti response -
integrating a fix to this I'd deem pretty high priority :)
F
thanks,
cfh