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

Use of messages variable causes conflict in django messages framework #5

Closed
scaryclam opened this issue Aug 11, 2011 · 6 comments
Closed

Comments

@scaryclam
Copy link

Hi,

we use the django messages framework to pass notices to pages in our website. Unfortunately rosetta uses the local variable messages (line 200 in views.py). Due to the variable being named "messages" and the variable being returned in the response context we've found that the messages framework gets trodden on.

Would it be possible to use a different name for this variable in views.py (and pofile.html)?

@mbi
Copy link
Owner

mbi commented Aug 13, 2011

Not sure I understand the issue here: the message variable is local to the context of Rosetta, and is displayed in an isolated manner inside a Rosetta template, how would if affect your message framework?

@scaryclam
Copy link
Author

We were customising the rosetta template to fit in with the look and feel of our website by putting it into the local project under templates/rosetta. Because rosetta uses "messages" as the variable name, the usual messages framework is unusable for any of the customised rosetta templates.

We're now using a patched version of rosetta (changing "messages" to "rosetta_msgs") which allows rosetta and the django messaging framework to co-exist properly.

The issue is simply the use of the variable name "messages" when integrating rosetta into websites that also make use of django messages to convey information back to users.

Hope that makes the issue clearer.

@mbi
Copy link
Owner

mbi commented Aug 27, 2011

Okay, I hope you'll agree this isn't an issue with Rosetta then, and probably best taken care of in a fork.

@mbi mbi closed this as completed Aug 27, 2011
@scaryclam
Copy link
Author

It seems more of a naming issue to me. The messages variable name is part of django. Would it not just be possible to use a variable such as rosetta_messages rather than conflicting with django? It's only used in two places and anyone who uses django messages and rosetta will get this issue.

@mbi
Copy link
Owner

mbi commented Aug 30, 2011

Anyone who uses Rosetta embedded into the global admin, you mean? Or am I missing something again?
Anyway, I'll accept a pull request that addresses this issue, as long as it's fully tested.

@scaryclam
Copy link
Author

It can affect anyone just trying to use the messages framework in their site alongside rosetta that has been edited to fit in with their look and feel. Basically, the home() view in views.py puts locals() into the context. Djangos messages framework also uses the messages variable name. So when a project puts something like:

{% if messages %}
<ul class="messages">
    {% for message in messages %}
    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
    {% endfor %}
</ul>
{% endif %}

into a template like base.html, django messages spits out all of the rosetta languages stored in the messages variable onto the page. So the project must either copy the above code into every template where they might want to see messages appear (tedious for even a medium project) or patch rosetta to use a less general variable name.

I've make a fork and applied some changes but am wondering if you have any specific tests for templates. If not I'll set up a test project and make sure it all works as expected before making a pull request.

Thanks,

Becky Lewis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants