Skip to content

Commit

Permalink
removed request.current_app and updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
digi604 committed Jun 13, 2013
1 parent 587ce89 commit cd2fa36
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Expand Up @@ -186,5 +186,7 @@ Please see Install/2.4 release notes *before* attempting to upgrade to version 2
- Removed CMS_SHOW_END_DATE. Always enabled.
- Added (optional) language fallback for placeholders.
- moved apphooks from title to page model so we need to add them only once.
- request.current_app has been removed.
- added a namespace field, reverse_id is not used anymore for apphook namespaces.


12 changes: 0 additions & 12 deletions cms/middleware/page.py
Expand Up @@ -15,19 +15,7 @@ def __get__(self, request, obj_type=None):
return request._current_page_cache


class LazyPageApp(object):
def __get__(self, request, obj_type=None):
if not hasattr(request, '_current_app_cache'):
page = request.current_page
if page and page.application_namespace:
request._current_app_cache = page.application_namespace
else:
request._current_app_cache = None
return request._current_app_cache


class CurrentPageMiddleware(object):
def process_request(self, request):
request.__class__.current_page = LazyPage()
request.__class__.current_app = LazyPageApp()
return None
4 changes: 3 additions & 1 deletion cms/test_utils/project/sampleapp/views.py
Expand Up @@ -8,7 +8,9 @@


def sample_view(request, **kw):
response_kwargs = {'current_app': resolve(request.path).namespace, 'dict_': kw}
app = resolve(request.path).namespace
kw['app'] = app
response_kwargs = {'current_app': app, 'dict_': kw}
context = RequestContext(request, **response_kwargs)
return render_to_response("sampleapp/home.html", context_instance=context)

Expand Down
2 changes: 1 addition & 1 deletion docs/extending_cms/app_integration.rst
Expand Up @@ -292,7 +292,7 @@ If you add this menu now to your app-hook::
You get the static entries of :class:`MyAppMenu` and the dynamic entries of
:class:`CategoryMenu` both attached to the same page.


.. _multi_apphook:
Attaching an Application multiple times
---------------------------------------

Expand Down
26 changes: 26 additions & 0 deletions docs/upgrade/3.0.rst
Expand Up @@ -175,3 +175,29 @@ Plugin Context Processors take a new argument
of the context is available to them. So if you have existing Plugin Context
Processors you will need to change their function signature to add the extra
argument.

Apphooks
========

Apphooks have moved from the title to the page model. This means there are no
more separate apphooks possible per language. A new namespace field has been
added.

.. note::
The reverse id is not used for the namespace anymore.
If you used namespaced apphooks before, be sure to update your pages and fill out the namespace fields.

If you use apphook apps with ``app_name`` for app namespaces be sure to fill out the namespace field as of now
it is required to have a namespace defined if you use app namespaces.

``request.current_app`` has been removed. If you relied on this, use the following
code instead in your views::

def my_view(request):
current_app = resolve(request.path).namespace
context = RequestContext(request, current_app=current_app)
return render_to_response("my_templace.html", context_instance=context)



Details can be found here: :ref:`multi_apphook`

0 comments on commit cd2fa36

Please sign in to comment.