From bb40239ed0bf2d9a99c699de82d7541c2a891d3f Mon Sep 17 00:00:00 2001 From: Massimo Date: Thu, 17 Jan 2013 17:33:17 -0600 Subject: [PATCH] fixed searilization of request/response/session in tickets (they are stored as html, thanks Dominik --- VERSION | 2 +- applications/admin/views/default/ticket.html | 265 +++++++++---------- gluon/html.py | 4 +- gluon/restricted.py | 6 +- gluon/tools.py | 2 +- 5 files changed, 132 insertions(+), 147 deletions(-) diff --git a/VERSION b/VERSION index 24d61477..8fb8ecd6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2013.01.17.11.34.20 +Version 2.4.1-alpha.2+timestamp.2013.01.17.17.32.33 diff --git a/applications/admin/views/default/ticket.html b/applications/admin/views/default/ticket.html index 538ec111..40a84969 100644 --- a/applications/admin/views/default/ticket.html +++ b/applications/admin/views/default/ticket.html @@ -7,148 +7,133 @@ {{if output:}}

{{=output}}

{{pass}}

{{=T('Version')}}

- - - - + + + + + + {{if snapshot:}} + + + - {{if snapshot:}} - - - - - {{pass}} - + {{pass}} +
web2py™{{=myversion}}
web2py™{{=myversion}}
Python{{=snapshot.get('pyver','')}}
Python{{=snapshot.get('pyver','')}}
{{if traceback or code or layer:}} -

{{=T('Traceback')}}

-
{{=traceback}}
- {{if snapshot:}} - {{try:}} - -

{{=T('Error snapshot')}} - - {{=helpicon()}} - {{=T("Detailed traceback description")}} - -

- -
- -

- {{=snapshot['etype']}}({{=snapshot['evalue']}}) -

-

- {{=T('inspect attributes')}} -

-
-
-
{{=T("Exception instance attributes")}}
- - - {{for k,v in snapshot['exception'].items():}} - - - - - {{pass}} - -
{{=k}}{{=v}}
-
-
-
- -
-

{{=T('Frames')}}

- -
- -
-

Context

-

- {{=T('locals')}} - {{=T('request')}} - {{=T('session')}} - {{=T('response')}} -

-
locals
- {{try:}} - {{=BEAUTIFY(snapshot['locals'])}} - {{except:}} - {{=BEAUTIFY('no locals available in snapshot')}} - {{pass}} -
-
request
- {{try:}} - {{=BEAUTIFY(snapshot['request'])}} - {{except:}} - {{=BEAUTIFY('no request available in snapshot')}} - {{pass}} -
-
session
- {{try:}} - {{=BEAUTIFY(snapshot['session'])}} - {{except:}} - {{=BEAUTIFY('no session available in snapshot')}} - {{pass}} -
-
response
- {{try:}} - {{=BEAUTIFY(snapshot['response'])}} - {{except:}} - {{=BEAUTIFY('no response available in snapshot')}} - {{pass}} -
-
- {{except Exception, e:}} - - {{import traceback;tb=traceback.format_exc().replace("\n","\\n") }} - - {{pass}} - {{pass}} -
-

In file: {{=layer}}

- {{=CODE(code.replace('\r',''),language='python',link='/examples/global/vars/')}} +

{{=T('Traceback')}}

+
{{=traceback}}
+{{if snapshot:}} +{{try:}} + +

{{=T('Error snapshot')}} + + {{=helpicon()}} + {{=T("Detailed traceback description")}} + +

+ +
+ +

+ {{=snapshot['etype']}}({{=snapshot['evalue']}}) +

+

+ {{=T('inspect attributes')}} +

+
+
+

{{=T("Exception instance attributes")}}

+ + + {{for k,v in snapshot['exception'].items():}} + + + + + {{pass}} + +
{{=k}}{{=v}}
+
+
+
+ +
+

{{=T('Frames')}}

+
    + {{for i, frame in enumerate(snapshot['frames']):}} +
  • + {{is_hidden = (i != len(snapshot['frames'])-1 and 'hide' or 'inspect')}} +
    +

    + File {{="%s in %s at line %s" % (frame['file'], frame['func'], frame['lnum'])}} + {{=T("code")}} + {{=T("arguments")}} + {{=T("variables")}} +

    +
    +
    Function argument list
    +

    {{=frame['call']}}

    -{{else:}} -

    {{=T('Ticket Missing')}}

    +
    +
    Code listing
    + {{if frame['lines']:}} +
    {{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
    +	    language='python', link=None, counter=min(frame['lines'].keys()), highlight_line=frame['lnum'])}}
    + {{pass}} +
    +
    +
    Variables
    + + + {{for k,v in frame['dump'].items():}} + + + + + {{pass}} + +
    {{=k}}{{=v}}
    +
    +
    +
  • + {{pass}} +
+
+ +
+

Context

+

+ {{=T('locals')}} + {{=T('request')}} + {{=T('session')}} + {{=T('response')}} +

+

locals

+ {{=BEAUTIFY(snapshot.get('locals','no locals available in snapshot'))}} +
+

request

+ {{=XML(snapshot.get('request','no request available in snapshot'))}} +
+

session

+ {{=XML(snapshot.get('session','no session available in snapshot'))}} +
+

response

+ {{=XML(snapshot.get('response','no response available in snapshot'))}} +
+
+{{except Exception, e:}} + +{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }} + {{pass}} - \ No newline at end of file +{{pass}} + +
+

In file: {{=layer}}

+ {{=CODE(code.replace('\r',''),language='python',link='/examples/global/vars/')}} +
+{{else:}} +

{{=T('Ticket Missing')}}

+{{pass}} + diff --git a/gluon/html.py b/gluon/html.py index 265f5500..c8e37ed8 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -2243,9 +2243,9 @@ class BEAUTIFY(DIV): for c in self.components: if hasattr(c, 'value') and not callable(c.value): if c.value: - components.append(c.value) + components.append(c.value) if hasattr(c, 'xml') and callable(c.xml): - components.append(c) + c = str(c) continue elif hasattr(c, 'keys') and callable(c.keys): rows = [] diff --git a/gluon/restricted.py b/gluon/restricted.py index c6649601..7d5ca513 100644 --- a/gluon/restricted.py +++ b/gluon/restricted.py @@ -16,7 +16,7 @@ import logging from storage import Storage from http import HTTP -from html import BEAUTIFY +from html import BEAUTIFY, XML logger = logging.getLogger("web2py") @@ -131,7 +131,7 @@ class RestrictedError(Exception): try: self.traceback = traceback.format_exc() except: - self.traceback = 'no traceback because template parting error' + self.traceback = 'no traceback because template parsing error' try: self.snapshot = snapshot(context=10, code=code, environment=self.environment) @@ -319,6 +319,6 @@ def snapshot(info=None, context=5, code=None, environment=None): # add web2py environment variables for k, v in environment.items(): if k in ('request', 'response', 'session'): - s[k] = BEAUTIFY(v) + s[k] = XML(str(BEAUTIFY(v))) return s diff --git a/gluon/tools.py b/gluon/tools.py index fec9b7cd..388c1178 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -5091,7 +5091,7 @@ class Wiki(object): '%(slug)s')), comment=current.T( "Choose Template or empty for new Page"))) - form = SQLFORM.factory(*fields, _class="well span6") + form = SQLFORM.factory(*fields, **dict(_class="well span6")) form.element("[type=submit]").attributes["_value"] = \ current.T("Create Page from Slug")