[Erp5-dev] [Erp5-report] r32380 jm - in /erp5/trunk/products/ERP5Form: Form.py ListBox.py
Julien Muchembled
jm at nexedi.com
Fri Feb 12 13:25:02 CET 2010
Hello,
The change in [32380:32381] for erp5/trunk/products/ERP5Form/ListBox.py is:
@@ -2342,15 +2342,13 @@ def render(self):
html += u' <span class="error">%s</span>' % error_message
else:
# If not editable, show a static text with a link, if enabled.
- processed_value = cgi.escape(processed_value)
- if url is None:
- html = processed_value
- else:
+ html = cgi.escape(processed_value)
+ if url is not None:
# JPS-XXX - I think we should not display a URL for objects
# which do not have the View permission
- if type(url) is str:
+ if isinstance(url, str):
url = unicode(url, encoding)
- html = u'<a href="%s">%s</a>' % (url, processed_value)
+ html = u'<a href="%s">%s</a>' % (url, html)
html_list.append((html, original_value, error, editable_field, url))
The optimization here is only the removal of an assignment.
I replaced 'type(url) is str' by 'isinstance(url, str)' as recommended by Python documentation but:
- 'type(url) is str' still works in Python 3.1
- 'isinstance(url, str)' is 50% slower than 'type(url) is str' on all versions of Python.
Julien
nobody at svn.erp5.org a écrit :
> Author: jm
> Date: Tue Feb 9 19:53:27 2010
> New Revision: 32380
>
> URL: http://svn.erp5.org?rev=32380&view=rev
> Log:
> Small optimizations
>
> Modified:
> erp5/trunk/products/ERP5Form/Form.py
> erp5/trunk/products/ERP5Form/ListBox.py
>
> Modified: erp5/trunk/products/ERP5Form/Form.py
> URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/Form.py?rev=32380&r1=32379&r2=32380&view=diff
> ==============================================================================
> --- erp5/trunk/products/ERP5Form/Form.py [utf8] (original)
> +++ erp5/trunk/products/ERP5Form/Form.py [utf8] Tue Feb 9 19:53:27 2010
> @@ -611,15 +611,9 @@
> # staff. The only real solution is to use a special
> # permission (ex. AccessPrivateInformation) for those
> # properties which are sensitive.
> - if not kwargs.has_key('args'):
> - kwargs['args'] = args
> - if kwargs.has_key('key_prefix'):
> - key_prefix = kwargs['key_prefix']
> - del(kwargs['key_prefix'])
> - else:
> - key_prefix = None
> - form = self
> - obj = getattr(form, 'aq_parent', None)
> + kwargs.setdefault('args', args)
> + key_prefix = kwargs.pop('key_prefix', None)
> + obj = getattr(self, 'aq_parent', None)
> if obj is not None:
> container = obj.aq_inner.aq_parent
> if not _checkPermission(Permissions.View, obj):
>
> Modified: erp5/trunk/products/ERP5Form/ListBox.py
> URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/ListBox.py?rev=32380&r1=32379&r2=32380&view=diff
> ==============================================================================
> --- erp5/trunk/products/ERP5Form/ListBox.py [utf8] (original)
> +++ erp5/trunk/products/ERP5Form/ListBox.py [utf8] Tue Feb 9 19:53:27 2010
> @@ -2342,15 +2342,13 @@
> html += u' <span class="error">%s</span>' % error_message
> else:
> # If not editable, show a static text with a link, if enabled.
> - processed_value = cgi.escape(processed_value)
> - if url is None:
> - html = processed_value
> - else:
> + html = cgi.escape(processed_value)
> + if url is not None:
> # JPS-XXX - I think we should not display a URL for objects
> # which do not have the View permission
> - if type(url) is str:
> + if instance(url, str):
> url = unicode(url, encoding)
> - html = u'<a href="%s">%s</a>' % (url, processed_value)
> + html = u'<a href="%s">%s</a>' % (url, html)
>
> html_list.append((html, original_value, error, editable_field, url))
>
>
> _______________________________________________
> Erp5-report mailing list
> Erp5-report at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-report
More information about the Erp5-dev
mailing list