X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/ba4bab73996c40c2551f7e5a0e478d0f553b8af3..957c1a654f871388f37195315b6797bfbcda6a5e:/docs/models/nodes-and-views.rst?ds=inline diff --git a/docs/models/nodes-and-views.rst b/docs/models/nodes-and-views.rst index ee63291..7fd5665 100644 --- a/docs/models/nodes-and-views.rst +++ b/docs/models/nodes-and-views.rst @@ -1,70 +1,25 @@ Nodes and Views: Building Website structure =========================================== -.. currentmodule:: philo.models +.. automodule:: philo.models.nodes Nodes ----- -:class:`Node`\ s are the basic building blocks of a website using Philo. They define the URL hierarchy and connect each URL to a :class:`View` subclass instance which is used to generate an HttpResponse. - -.. class:: Node - - :class:`!Node` subclasses :class:`TreeEntity`. It defines the following additional methods and attributes: - - .. attribute:: view - - :class:`GenericForeignKey` to a non-abstract subclass of :class:`View` - - .. attribute:: accepts_subpath - - A property shortcut for :attr:`self.view.accepts_subpath ` - - .. method:: render_to_response(request[, extra_context=None]) - - This is a shortcut method for :meth:`View.render_to_response` - - .. method:: get_absolute_url() - - As long as :mod:`philo.urls` is included somewhere in the urlpatterns, this will return the URL of this node. The returned value will always start and end with a slash. +.. autoclass:: Node + :show-inheritance: + :members: + :exclude-members: attribute_set Views ----- Abstract View Models ++++++++++++++++++++ -.. class:: View - - :class:`!View` is an abstract model that represents an item which can be "rendered", either in response to an :class:`HttpRequest` or as a standalone. It subclasses :class:`Entity`, and defines the following additional methods and attributes: - - .. attribute:: accepts_subpath - - Defines whether this View class can handle subpaths. Default: ``False`` - - .. attribute:: nodes - - A generic relation back to nodes. - - .. method:: get_subpath(obj) - - If the view :attr:`accepts subpaths <.accepts_subpath>`, try to find a reversal for the given object using ``self`` as the urlconf. This method calls :meth:`~.get_reverse_params` with ``obj`` as the argument to find out the reversing parameters for that object. - .. method:: get_reverse_params(obj) - - This method should return a ``view_name``, ``args``, ``kwargs`` tuple suitable for reversing a url for the given ``obj`` using ``self`` as the urlconf. - - .. method:: attributes_with_node(node) - - Returns a :class:`QuerySetMapper` using the :class:`node `'s attributes as a passthrough. - - .. method:: render_to_response(request[, extra_context=None]) - - Renders the :class:`View` as an :class:`HttpResponse`. This will raise :const:`philo.exceptions.MIDDLEWARE_NOT_CONFIGURED` if the `request` doesn't have an attached :class:`Node`. This can happen if :class:`philo.middleware.RequestNodeMiddleware` is not in :setting:`settings.MIDDLEWARE_CLASSES` or if it is not functioning correctly. - - :meth:`!render_to_response` will send the :obj:`view_about_to_render ` signal, then call :meth:`actually_render_to_response`, and finally send the :obj:`view_finished_rendering ` signal before returning the ``response``. - - .. method:: actually_render_to_response(request[, extra_context=None]) - - Concrete subclasses must override this method to provide the business logic for turning a ``request`` and ``extra_context`` into an :class:`HttpResponse`. +.. autoclass:: View + :show-inheritance: + :members: + :exclude-members: attribute_set .. class:: MultiView @@ -101,13 +56,25 @@ Concrete View Subclasses A choices tuple of redirect status codes (temporary or permanent). - .. attribute:: target + .. attribute:: status_code + + An :class:`IntegerField` which uses :attr:`STATUS_CODES` as its choices. Determines whether the redirect is considered temporary or permanent. + + .. attribute:: target_node + + An optional :class:`ForeignKey` to a :class:`Node`. If provided, that node will be used as the basis for the redirect. + + .. attribute:: url_or_subpath A :class:`CharField` which may contain an absolute or relative URL. This will be validated with :class:`philo.validators.RedirectValidator`. - .. attribute:: status_code + .. attribute:: reversing_parameters - An :class:`IntegerField` which uses :attr:`STATUS_CODES` as its choices. Determines whether the redirect is considered temporary or permanent. + A :class:`~philo.models.fields.JSONField` instance. If the value of :attr:`reversing_parameters` is not None, the :attr:`url_or_subpath` will be treated as the name of a view to be reversed. The value of :attr:`reversing_parameters` will be passed into the reversal as args if it is a list or as kwargs if it is a dictionary. + + .. attribute:: target_url + + Calculates and returns the target url based on the :attr:`target_node`, :attr:`url_or_subpath`, and :attr:`reversing_parameters`. .. method:: actually_render_to_response(request[, extra_context=None])