-:class:`Page`\ s are the most frequently used :class:`View` subclass. They define a basic HTML page and its associated content. Each :class:`Page` renders itself according to a :class:`Template`. The :class:`Template` may contain :ttag:`container` tags, which define related :class:`Contentlet`\ s and :class:`ContentReference`\ s for any page using that :class:`Template`.
-
-.. class:: Page
-
- A :class:`View` subclass. Represents a page - something which is rendered according to a template. The page will have a number of related Contentlets depending on the template selected - but these will appear only after the page has been saved with that template.
-
- .. attribute:: template
-
- A :class:`ForeignKey` to the :class:`Template` used to render this :class:`Page`.
-
- .. attribute:: title
-
- The name of this page. Chances are this will be used for organization - i.e. finding the page in a list of pages - rather than for display.
-
- .. attribute:: containers
-
- Returns :attr:`self.template.containers <Template.containers>` - a tuple containing the specs of all :ttag:`container`\ s defined in the :class:`Template`. The value will be cached on the instance so that multiple accesses will be less expensive.
-
- .. method:: render_to_string([request=None, extra_context=None])
-
- 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-related content with the same :ttag:`container`-based functionality as is used for HTML.
-
- .. method:: actually_render_to_response(request[, extra_context=None])
-
- Returns an :class:`HttpResponse` with the content of the :meth:`render_to_string` method and the mimetype set to :attr:`self.template.mimetype <Template.mimetype>`.
-
- .. clean_fields(self[, exclude=None)
-
- This is an override of the default model clean_fields method. Essentially, in addition to validating the fields, this method validates the :class:`Template` instance that is used to render this :class:`Page`. This is useful for catching template errors before they show up as 500 errors on a live site.
-
- .. method:: __unicode__()
-
- Returns :meth:`self.title <title>`
-
-.. class:: Template
-
- Subclasses :class:`TreeModel`. Represents a database-driven django template. Defines the following additional methods and attributes:
-
- .. attribute:: name
-
- The name of the template. Used for organization and debugging.
-
- .. attribute:: documentation
-
- Can be used to let users know what the template is meant to be used for.
-
- .. attribute:: mimetype
-
- Defines the mimetype of the template. This is not validated. Default: ``text/html``.
-
- .. attribute:: code
-
- An insecure :class:`~philo.models.fields.TemplateField` containing the django template code for this template.
-
- .. attribute:: containers
-
- Returns a tuple where the first item is a list of names of contentlets referenced by containers, and the second item is a list of tuples of names and contenttypes of contentreferences referenced by containers. This will break if there is a recursive extends or includes in the template code. Due to the use of an empty Context, any extends or include tags with dynamic arguments probably won't work.
-
- .. method:: __unicode__()
-
- Returns the results of the :meth:`~TreeModel.get_path` method, using the "name" field and a chevron joiner.
-
-.. class:: Contentlet
-
- Defines a piece of content on a page. This content is treated as a secure :class:`~philo.models.fields.TemplateField`.
-
- .. attribute:: page
-
- The page which this :class:`Contentlet` is related to.
-
- .. attribute:: name
-
- This represents the name of the container as defined by a :ttag:`container` tag.
-
- .. attribute:: content
-
- A secure :class:`~philo.models.fields.TemplateField` holding the content for this :class:`Contentlet`. Note that actually using this field as a template requires use of the :ttag:`include_string` template tag.
-
- .. method:: __unicode__()
-
- Returns :attr:`self.name <name>`
-
-.. class:: ContentReference
-
- Defines a model instance related to a page.
-
- .. attribute:: page
-
- The page which this :class:`ContentReference` is related to.
-
- .. attribute:: name
-
- This represents the name of the container as defined by a :ttag:`container` tag.