def render(self, context): assert "request" in context, "AdSense tag requires request in context." if self.publisher_id is not None: publisher_id = self.publisher_id.resolve(context) else: publisher_id = default_publisher_id if publisher_id is None: raise ImproperlyConfigured("No AdSense publisher id given.") return adsense(context["request"], publisher_id, fail_silently=fail_silently)
def render(self, context): assert "request" in context, "AdSense tag requires request in context." if self.publisher_id is not None: publisher_id = self.publisher_id.resolve(context) else: publisher_id = default_publisher_id if self.slot_id is not None: slot_id = self.slot_id.resolve(context) else: slot_id = default_slot_id if publisher_id is None or slot_id is None: raise ImproperlyConfigured("No AdSense publisher or slot id given.") res = adsense(context["request"], publisher_id, slot_id, fail_silently=fail_silently) if not res or res == '<!-- google_afm -->': res = render(context["request"], default_template).content return res