X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/ac6ebd8b38a46afb0b249574be71a276f95b6efa..85eb51c030b89dba1c940a8508f1ae1ced1178d4:/philo/models/pages.py?ds=sidebyside diff --git a/philo/models/pages.py b/philo/models/pages.py index ae64b4d..bdd9b42 100644 --- a/philo/models/pages.py +++ b/philo/models/pages.py @@ -10,7 +10,7 @@ from django.contrib.contenttypes import generic from django.core.exceptions import ValidationError from django.db import models from django.http import HttpResponse -from django.template import TemplateDoesNotExist, Context, RequestContext, Template as DjangoTemplate, add_to_builtins as register_templatetags, TextNode, VariableNode +from django.template import TemplateDoesNotExist, Context, RequestContext, Template as DjangoTemplate, TextNode, VariableNode from django.template.loader_tags import BlockNode, ExtendsNode, BlockContext from django.utils.datastructures import SortedDict @@ -23,6 +23,9 @@ from philo.utils import fattr from philo.validators import LOADED_TEMPLATE_ATTR +__all__ = ('Template', 'Page', 'Contentlet', 'ContentReference') + + class LazyContainerFinder(object): def __init__(self, nodes, extends=False): self.nodes = nodes @@ -170,6 +173,8 @@ class Page(View): """ In addition to rendering as an :class:`HttpResponse`, a :class:`Page` can also render as a string. This means, for example, that :class:`Page`\ s can be used to render emails or other non-HTML content with the same :ttag:`container`-based functionality as is used for HTML. + The :class:`Page` will add itself to the context as ``page`` and its :attr:`~.Entity.attributes` as ``attributes``. If a request is provided, then :class:`request.node <.Node>` will also be added to the context as ``node`` and ``attributes`` will be set to the result of calling :meth:`~.View.attributes_with_node` with that :class:`.Node`. + """ context = {} context.update(extra_context or {}) @@ -258,8 +263,5 @@ class ContentReference(models.Model): app_label = 'philo' -register_templatetags('philo.templatetags.containers') - - register_value_model(Template) register_value_model(Page) \ No newline at end of file