Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Django 1.11 support #289

Closed
3 tasks done
aarranz opened this issue Jun 19, 2017 · 11 comments
Closed
3 tasks done

Add Django 1.11 support #289

aarranz opened this issue Jun 19, 2017 · 11 comments

Comments

@aarranz
Copy link
Member

aarranz commented Jun 19, 2017

Update WireCloud to work on Django 1.11

  • Create a jenkins job using Django 1.11
  • Replace RequestContext and Context instances by simple dictionaries.
  • Update setup.py
@brylie
Copy link
Contributor

brylie commented Jun 20, 2017

Are there any sub-tasks related to this?

@aarranz
Copy link
Member Author

aarranz commented Jun 20, 2017

Well, I've added some subtasks to the ticket description... but probably the list is not complete.

@brylie
Copy link
Contributor

brylie commented Jun 20, 2017

Alright. I would like to help with any small, repetitive tasks. E.g. replacing RequestContext and Context in some simple view classes/functions.

@aarranz
Copy link
Member Author

aarranz commented Jun 20, 2017

Great, waiting a pull request 😄.

Don't hesitate to ask us anything about testing the development code of WireCloud using Django 1.11.

@brylie
Copy link
Contributor

brylie commented Jun 20, 2017

I found one use of RequestContext in /wirecloud/platform/theme/views.py:59. What would the proposed change to the RequestContent and template.render lines look like?

I am new to Django, so need a bit of guidance to understand how things are working.

@brylie
Copy link
Contributor

brylie commented Jun 20, 2017

I found two files where Context is used:

Is the idea here to just replace the Context instances with plain dicts?

@brylie
Copy link
Contributor

brylie commented Jun 20, 2017

PR #290 opened for Context refactor. Please review.

@brylie
Copy link
Contributor

brylie commented Jun 20, 2017

The Django Template.render() docs still mention using a Context instance.

from django.template import Context, Template
>>> template = Template("My name is {{ my_name }}.")

>>> context = Context({"my_name": "Adrian"})
>>> template.render(context)

What changes should I make to /widgets/utils.py and /wiring/utils.py?

@aarranz
Copy link
Member Author

aarranz commented Jun 20, 2017

Well, I know Context and RequestContext instances are not working anymore because I get an error when running WireCloud using Django 1.11:

Internal Server Error: /api/theme/wirecloud.defaulttheme
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/aarranz/src/wirecloud/src/wirecloud/commons/baseviews/resource.py", line 58, in __call__
    response = getattr(self, METHOD_MAPPING[request_method])(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Users/aarranz/src/wirecloud/src/wirecloud/platform/theme/views.py", line 78, in read
    desc["templates"][template_id] = template.render(context)
  File "/usr/local/lib/python2.7/site-packages/django/template/backends/django.py", line 64, in render
    context = make_context(context, request, autoescape=self.backend.engine.autoescape)
  File "/usr/local/lib/python2.7/site-packages/django/template/context.py", line 287, in make_context
    raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than RequestContext.

Also, Django 1.11 releases notes documents this change...

Context and ContextRequest classes continue being there so I don't know if they can be used for other purposes or being used in a compatibility mode... Anyway, dictionaries seems to be working properly on Django 1.8, so we can remove those classes without any problem. In that sense, your PR looks good to me, except by the fact that there is a RequestContext reference in wirecloud/platform/theme/views.py. Once added that change it can be merged 👍.

Thanks!

@aarranz
Copy link
Member Author

aarranz commented Jun 22, 2017

Jenkins says that WireCloud passes all the tests when using Django 1.11 :).

https://build.conwet.fi.upm.es/jenkins/view/Wirecloud/job/wirecloud-1.1.x-python2.7-django1.11/

@brylie Thanks for your support!

@aarranz aarranz closed this as completed Jun 22, 2017
@aarranz aarranz added this to the Jun 2017 milestone Jun 22, 2017
@brylie
Copy link
Contributor

brylie commented Jun 22, 2017

Great project! Thanks for your dedicated work as well :-)

Mognom pushed a commit to Mognom/wirecloud that referenced this issue Jul 24, 2017
Mognom pushed a commit to Mognom/wirecloud that referenced this issue Jul 24, 2017
Mognom pushed a commit to Mognom/wirecloud that referenced this issue Jul 24, 2017
Mognom pushed a commit to Mognom/wirecloud that referenced this issue Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants