We had this code and it worked fine. After doing a refactor, it doesn't work anymore. Like the comment says, we only want to inherit from a base page if the request isn't an ajax request. To do this, we pass a parameter to the template, and, based on the parameter, we inherit or not.
View.py
class Router(object):
def __init__(self, request):
self.request = request
@view_config(route_name="home")
def get(self):
template = "home.mak"
value = {'isPage':self.request.is_xhr is False}
return render_to_response(template, value, request=self.request)
Template.mak
##conditional to determine with the template should inherit from the base page
##it shouldn't inherit from the base page is it is being inserted into the page using ajax
<%!
def inherit(context):
if context.get('isPage') == True:
return "base.mak"
else:
return None
%>
<%inherit file="${inherit(context)}"/>
Currently, the error is Undefined does not have attribute __getitem__. If we change ${inherit(context)} to ${inherit(value)} we get global variable value is undefined.