add extra data to response object to render in template
Posted
by mp0int
on Stack Overflow
See other posts from Stack Overflow
or by mp0int
Published on 2010-06-10T07:12:10Z
Indexed on
2010/06/10
8:02 UTC
Read the original article
Hit count: 213
I ned to write a code sniplet that enables to disable connection to some parts of a site. Admin and the mainpage will be displayable, but user section (which uses ajax) will be displayed, but can not be used (vith a transparent div set over the page). Also there is a few pages which will be disabled.
my logic is that, i write a middleware,
def process_request(self, request):
if ayar.tonline_kapali:
url_parcalari = request.path.split('/')
if url_parcalari[0] not in settings.BAGIMSIZ_URLLER:
if not request.is_ajax():
return render_to_response('bakim_modu.html')
else:
return None
that code let me to display a "site closed" message for the urls not in BAGIMSIZ_URLLER (which contains urls that will be accessible)
But i do not figure out how can i solve the problem about ajax pages... i need to set a header or something to the response and need to check it in the template.
© Stack Overflow or respective owner