Vanilla versionutils.deprecated fails for classes (intended only for functions)

Bug #1335800 reported by Timur Sufiev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Murano
Fix Released
Medium
Timur Sufiev

Bug Description

More specifically, classes wrapped with that decorator fail inside dynamic UI machinery with:

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 72, in __call__
    return self.application(environ, start_response)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
    response = self.get_response(request)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/horizon/decorators.py", line 38, in dec
    return view_func(request, *args, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/horizon/decorators.py", line 54, in dec
    return view_func(request, *args, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/horizon/decorators.py", line 38, in dec
    return view_func(request, *args, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/catalog/views.py", line 141, in __inner
    return func(request, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/catalog/views.py", line 173, in __inner
    return func(request, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/.venv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/catalog/views.py", line 195, in deploy
    do_redirect=do_redirect, drop_wm_form=drop_wm_form)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/catalog/views.py", line 141, in __inner
    return func(request, **kwargs)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/catalog/views.py", line 238, in view
    forms = initforms(request, kwargs)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/services.py", line 163, in get_app_forms
    app = import_app(request, kwargs.get('app_id'))
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/services.py", line 149, in import_app
    app = _apps[app_id] = Service(app_data, **service)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/services.py", line 75, in __init__
    self._add_form(name, field_specs, validators)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/services.py", line 85, in _add_form
    class Form(forms.ServiceConfigurationForm):
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/forms.py", line 126, in __new__
    for field_name, field in _collect_fields(field_specs, name, service):
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/forms.py", line 118, in _collect_fields
    return [make_field(copy.deepcopy(_spec)) for _spec in field_specs]
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/forms.py", line 113, in make_field
    cls, kwargs['widget'] = process_widget(TYPES[_type], kwargs)
  File "/home/timur/develop/murano/murano-dashboard/muranodashboard/dynamic_ui/forms.py", line 63, in process_widget
    widget = kwargs.get('widget') or cls.widget
AttributeError: 'function' object has no attribute 'widget'

Tags: dashboard
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to murano-dashboard (master)

Fix proposed to branch: master
Review: https://review.openstack.org/103502

Changed in murano:
assignee: nobody → Timur Sufiev (tsufiev-x)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to murano-dashboard (master)

Reviewed: https://review.openstack.org/103502
Committed: https://git.openstack.org/cgit/stackforge/murano-dashboard/commit/?id=f72d7ea1a02b7da838d003b0092c18bffce96e90
Submitter: Jenkins
Branch: master

commit f72d7ea1a02b7da838d003b0092c18bffce96e90
Author: Timur Sufiev <email address hidden>
Date: Mon Jun 30 13:45:49 2014 +0400

    Enhance versionutils.deprecated to work with classes

    If object being decorated has 'func_code' attribute, it is considered
    a function (and processed by vanilla versionutils.deprecated),
    otherwise a new class is created which logs deprecated message when
    class is instantiated. Also 'Juno' release is added to possible
    deprecation milestones.

    Closes-Bug: #1335800
    Change-Id: I12e7ad00af3bac35138cc0f8c7d595a08e8eda03

Changed in murano:
status: In Progress → Fix Committed
ruhe (ruhe)
Changed in murano:
status: Fix Committed → Fix Released
Changed in murano:
milestone: juno-2 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.