Merge lp:~alecu/openobject-client/django-tracebacks into lp:openobject-client

Proposed by Alejandro J. Cura
Status: Work in progress
Proposed branch: lp:~alecu/openobject-client/django-tracebacks
Merge into: lp:openobject-client
Diff against target: 173 lines (+105/-3)
3 files modified
bin/common/common.py (+48/-2)
bin/tiny_socket.py (+7/-1)
bin/win_error.glade (+50/-0)
To merge this branch: bzr merge lp:~alecu/openobject-client/django-tracebacks
Reviewer Review Type Date Requested Status
Christophe CHAUVET Pending
Fabien (Open ERP) Pending
Review via email: mp+14710@code.launchpad.net

This proposal supersedes a proposal from 2009-11-09.

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote : Posted in a previous version of this proposal

PyWebkit support is optional; if not installed it shows a link to open the error in a browser.

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote : Posted in a previous version of this proposal

Hi

It's a great feature, but not for 5.0 branch, only bugfix in the stable branch

But if you made a patch for Trunk, i can test it :)

There is already a code (in openobject forum) to add new widget (webbrowser and sourceview)

http://www.openobject.com/forum/topic5676.html?highlight=webkit

Regards,

review: Disapprove
Revision history for this message
Alejandro J. Cura (alecu) wrote : Posted in a previous version of this proposal

> Hi
>
> It's a great feature, but not for 5.0 branch, only bugfix in the stable branch
>
> But if you made a patch for Trunk, i can test it :)

Hi,

I think that I made my patch against Trunk, to be included in future OpenObject versions.
Can you please tell what did you find wrong?

thanks,
--
alecu

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote : Posted in a previous version of this proposal

Nothing wrong, but cannot merge to the stable branch (only bugfix)

Regards,

Revision history for this message
Alejandro J. Cura (alecu) wrote : Posted in a previous version of this proposal

On Mon, Nov 9, 2009 at 15:46, Christophe Chauvet -
http://www.syleam.fr/ <email address hidden> wrote:
> Nothing wrong, but cannot merge to the stable branch (only bugfix)

Ok, perfect.
Would you mind telling what is the branch that I should propose to
merge my patch?

thanks!
--
alecu

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote : Posted in a previous version of this proposal

Sorry, but ot's the good branch

Regards,

review: Approve
Revision history for this message
Husen Daudi (husendaudi) wrote : Posted in a previous version of this proposal

Hello,

Great work, I have tested your code by merging client and server.
Error window is mode user friendly and well formated.
But we are getting whole html file as a traceback in client prompt.
In client terminal it prints long traceback and which looks dirty.
Is there any way to prevent that traceback?

Thanks,
HDA

Unmerged revisions

1014. By Alejandro J. Cura <email address hidden>

do not show the html in the console

1013. By Alejandro J. Cura <email address hidden>

[MERGE] merge from trunk

1012. By Alejandro J. Cura <email address hidden>

webkit was not the default

1011. By Alejandro J. Cura <email address hidden>

if the traceback is an html, show it using webkit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/common/common.py'
2--- bin/common/common.py 2009-10-20 10:55:28 +0000
3+++ bin/common/common.py 2009-11-10 20:00:27 +0000
4@@ -21,6 +21,13 @@
5
6 import gtk
7 from gtk import glade
8+try:
9+ import webkit
10+except ImportError:
11+ webkit = False
12+import codecs
13+import tempfile
14+
15 import gobject
16 from cgi import escape
17 import tools
18@@ -327,13 +334,23 @@
19 win.destroy()
20 return True
21
22+def parse_details(details):
23+ if not details.strip().startswith("<!DOCTYPE HTML"):
24+ return details, None
25+ else:
26+ from xml.etree import ElementTree
27+ element = ElementTree.fromstring(details)
28+ textdetails = element.find("body/pre").text
29+ return textdetails, details
30+
31 def error(title, message, details='', parent=None, disconnected_mode=False):
32 """
33 Show an error dialog with the support request or the maintenance
34 """
35 log = logging.getLogger('common.message')
36- details = get_client_environment() + details
37- log.error('Message %s: %s' % (str(message),details))
38+ client_env = get_client_environment()
39+ details, html_details = parse_details(details)
40+ log.error('Message %s: %s%s' % (str(message),client_env,details))
41
42 show_message = True
43
44@@ -420,6 +437,33 @@
45 details_buffer = gtk.TextBuffer()
46 details_buffer.set_text(details)
47 xmlGlade.get_widget('details_explanation').set_buffer(details_buffer)
48+ temp_filename = None
49+ if html_details is None:
50+ # older server
51+ xmlGlade.get_widget('notebook').remove_page(3)
52+ xmlGlade.get_widget('htmldetails_linkbutton').hide()
53+ elif not webkit:
54+ # webkit not installed, let's show a link
55+ xmlGlade.get_widget('notebook').remove_page(3)
56+ temp_file, temp_filename = tempfile.mkstemp(prefix="openerp-error",suffix=".html")
57+ codecs.open(temp_filename,"wb",encoding="utf-8").write(html_details)
58+ temp_uri = "file://" + os.path.normpath(temp_filename)
59+ xmlGlade.get_widget('htmldetails_linkbutton').set_uri(temp_uri)
60+ else:
61+ # full support
62+ win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
63+ xmlGlade.get_widget('notebook').remove_page(2)
64+ sw = xmlGlade.get_widget('scrolledwindow4')
65+ browser = webkit.WebView()
66+
67+ def set_scroll_adjustments_cb(view, hadjustment, vadjustment):
68+ sw.props.hadjustment = hadjustment
69+ sw.props.vadjustment = vadjustment
70+
71+ browser.connect("set-scroll-adjustments", set_scroll_adjustments_cb)
72+ sw.add(browser)
73+ browser.show()
74+ browser.load_string(html_details, "text/html", "iso-8859-15", "error:")
75
76 if show_message:
77 xmlGlade.get_widget('maintenance_explanation').set_markup(maintenance_contract_message)
78@@ -450,6 +494,8 @@
79 response = win.run()
80 parent.present()
81 win.destroy()
82+ if temp_filename is not None:
83+ os.remove(temp_filename)
84 return True
85
86 def message(msg, title=None, type=gtk.MESSAGE_INFO, parent=None):
87
88=== modified file 'bin/tiny_socket.py'
89--- bin/tiny_socket.py 2009-10-20 10:55:28 +0000
90+++ bin/tiny_socket.py 2009-11-10 20:00:27 +0000
91@@ -40,7 +40,13 @@
92 def __init__(self, faultCode, faultString):
93 self.faultCode = faultCode
94 self.faultString = faultString
95- self.args = (faultCode, faultString)
96+ self.args = (faultCode, self.stripHtml(faultString))
97+
98+ def stripHtml(self, description):
99+ if description.startswith("<!DOCTYPE HTML"):
100+ part1 = description.split('<pre class="textdetails">\n')[1]
101+ description = part1.split('</pre>')[0]
102+ return description
103
104 class mysocket:
105 def __init__(self, sock=None):
106
107=== modified file 'bin/win_error.glade'
108--- bin/win_error.glade 2008-12-31 13:34:48 +0000
109+++ bin/win_error.glade 2009-11-10 20:00:27 +0000
110@@ -358,6 +358,24 @@
111 <property name="padding">5</property>
112 </packing>
113 </child>
114+ <child>
115+ <widget class="GtkLinkButton" id="htmldetails_linkbutton">
116+ <property name="visible">True</property>
117+ <property name="can_focus">True</property>
118+ <property name="receives_default">True</property>
119+ <property name="has_tooltip">True</property>
120+ <property name="label" translatable="yes">Click here to see the full stacktrace</property>
121+ <property name="relief">GTK_RELIEF_NONE</property>
122+ <property name="xalign">0</property>
123+ <property name="response_id">0</property>
124+ <property name="uri"></property>
125+ </widget>
126+ <packing>
127+ <property name="expand">False</property>
128+ <property name="fill">False</property>
129+ <property name="position">6</property>
130+ </packing>
131+ </child>
132 </widget>
133 <packing>
134 <property name="position">2</property>
135@@ -376,6 +394,38 @@
136 <property name="tab_fill">False</property>
137 </packing>
138 </child>
139+ <child>
140+ <widget class="GtkVBox" id="details">
141+ <property name="visible">True</property>
142+ <child>
143+ <widget class="GtkScrolledWindow" id="scrolledwindow4">
144+ <property name="visible">True</property>
145+ <property name="can_focus">True</property>
146+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
147+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
148+ </widget>
149+ <packing>
150+ <property name="padding">5</property>
151+ </packing>
152+ </child>
153+ </widget>
154+ <packing>
155+ <property name="position">3</property>
156+ </packing>
157+ </child>
158+ <child>
159+ <widget class="GtkLabel" id="label3">
160+ <property name="visible">True</property>
161+ <property name="label" translatable="yes">&lt;i&gt;_Details&lt;/i&gt;</property>
162+ <property name="use_markup">True</property>
163+ <property name="use_underline">True</property>
164+ </widget>
165+ <packing>
166+ <property name="type">tab</property>
167+ <property name="position">3</property>
168+ <property name="tab_fill">False</property>
169+ </packing>
170+ </child>
171 </widget>
172 <packing>
173 <property name="position">2</property>