Swapped references to specific AttributeMappers in for vague references to dictionary...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 12 May 2011 18:23:06 +0000 (14:23 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 12 May 2011 19:40:00 +0000 (15:40 -0400)
docs/handling_requests.rst [new file with mode: 0644]
docs/middleware.rst [deleted file]
docs/models/entities.rst
docs/models/miscellaneous.rst
docs/utilities.rst
philo/exceptions.py
philo/models/base.py
philo/models/nodes.py
philo/utils/entities.py
philo/views.py

diff --git a/docs/handling_requests.rst b/docs/handling_requests.rst
new file mode 100644 (file)
index 0000000..940d541
--- /dev/null
@@ -0,0 +1,10 @@
+Handling Requests
+=================
+
+.. automodule:: philo.middleware
+       :members:
+
+.. automodule:: philo.views
+
+
+.. autofunction:: node_view(request[, path=None, **kwargs])
diff --git a/docs/middleware.rst b/docs/middleware.rst
deleted file mode 100644 (file)
index 4a5c05f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Middleware
-==========
-
-.. automodule:: philo.middleware
-       :members:
index 4127f56..c311d59 100644 (file)
@@ -39,7 +39,7 @@ Entities
 
 .. autoclass:: Entity
        :members:
-       :exclude-members: attribute_set
+       :exclude-members: attribute_set, get_attribute_mapper
 
 .. autoclass:: TreeManager
        :members:
@@ -47,7 +47,7 @@ Entities
 .. autoclass:: TreeEntity
        :show-inheritance:
        :members:
-       :exclude-members: attribute_set
+       :exclude-members: attribute_set, get_attribute_mapper
 
        .. attribute:: objects
 
index ea13db2..80b654b 100644 (file)
@@ -1,10 +1,8 @@
 Miscellaneous Models
 =============================
-.. currentmodule:: philo.models.nodes
 .. autoclass:: philo.models.nodes.TargetURLModel
        :members:
        :exclude-members: get_target_url
 
-.. currentmodule:: philo.models.base
 .. autoclass:: philo.models.base.Tag
        :members:
\ No newline at end of file
index cb66b45..d1386b1 100644 (file)
@@ -21,7 +21,7 @@ AttributeMappers
        :show-inheritance:
 
 LazyAttributeMappers
-++++++++++++++++++++
+--------------------
 
 .. autoclass:: LazyAttributeMapperMixin
        :members:
index 9a8908e..9f908c0 100644 (file)
@@ -6,15 +6,15 @@ MIDDLEWARE_NOT_CONFIGURED = ImproperlyConfigured("""Philo requires the RequestNo
 
 
 class ViewDoesNotProvideSubpaths(Exception):
-       """Raised by :meth:`View.reverse` when the View does not provide subpaths (the default)."""
+       """Raised by :meth:`.View.reverse` when the :class:`.View` does not provide subpaths (the default)."""
        silent_variable_failure = True
 
 
 class ViewCanNotProvideSubpath(Exception):
-       """Raised by :meth:`View.reverse` when the :class:`View` can not provide a subpath for the supplied arguments."""
+       """Raised by :meth:`.View.reverse` when the :class:`.View` can not provide a subpath for the supplied arguments."""
        silent_variable_failure = True
 
 
 class AncestorDoesNotExist(Exception):
-       """Raised by :meth:`TreeModel.get_path` if the root instance is not an ancestor of the current instance."""
+       """Raised by :meth:`.TreeEntity.get_path` if the root instance is not an ancestor of the current instance."""
        pass
\ No newline at end of file
index c361bdc..9533628 100644 (file)
@@ -43,7 +43,7 @@ class Titled(models.Model):
                abstract = True
 
 
-#: An instance of :class:`ContentTypeRegistryLimiter` which is used to track the content types which can be related to by :class:`ForeignKeyValue`\ s and :class:`ManyToManyValue`\ s.
+#: An instance of :class:`.ContentTypeRegistryLimiter` which is used to track the content types which can be related to by :class:`ForeignKeyValue`\ s and :class:`ManyToManyValue`\ s.
 value_content_type_limiter = ContentTypeRegistryLimiter()
 
 
@@ -310,7 +310,7 @@ class Entity(models.Model):
        
        def get_attribute_mapper(self, mapper=AttributeMapper):
                """
-               Returns a dictionary-like object which can be used to retrieve related :class:`Attribute`\ s' values directly.
+               Returns an :class:`.AttributeMapper` which can be used to retrieve related :class:`Attribute`\ s' values directly.
 
                Example::
 
@@ -492,7 +492,7 @@ class TreeEntity(Entity, TreeModel):
        
        def get_attribute_mapper(self, mapper=None):
                """
-               Returns a dictionary-like object which can be used to retrieve related :class:`Attribute`\ s' values directly. If an attribute with a given key is not related to the :class:`Entity`, then the object will check the parent's attributes.
+               Returns a :class:`.TreeAttributeMapper` or :class:`.AttributeMapper` which can be used to retrieve related :class:`Attribute`\ s' values directly. If an :class:`Attribute` with a given key is not related to the :class:`Entity`, then the mapper will check the parent's attributes.
 
                Example::
 
index c29ac2a..f29545a 100644 (file)
@@ -171,12 +171,12 @@ class View(Entity):
                """
                raise NotImplementedError("View subclasses must implement get_reverse_params to support subpaths.")
        
-       def attributes_with_node(self, node):
+       def attributes_with_node(self, node, mapper=LazyPassthroughAttributeMapper):
                """
-               Returns a dictionary-like object which can be used to directly retrieve the values of :class:`Attribute`\ s related to the :class:`View`, falling back on similar object which retrieves the values of the passed-in node and its ancestors.
+               Returns a :class:`LazyPassthroughAttributeMapper` which can be used to directly retrieve the values of :class:`Attribute`\ s related to the :class:`View`, falling back on the :class:`Attribute`\ s of the passed-in :class:`Node` and its ancestors.
                
                """
-               return LazyPassthroughAttributeMapper((self, node))
+               return mapper((self, node))
        
        def render_to_response(self, request, extra_context=None):
                """
index f52620f..b911451 100644 (file)
@@ -164,7 +164,12 @@ class LazyTreeAttributeMapper(LazyAttributeMapperMixin, TreeAttributeMapper):
 
 
 class PassthroughAttributeMapper(AttributeMapper):
-       """Given an iterable of :class:`Entities <philo.models.base.Entity>`, this mapper will fetch an :class:`AttributeMapper` for each one. Lookups will return the value from the first :class:`AttributeMapper` which has an entry for a given key."""
+       """
+       Given an iterable of :class:`Entities <philo.models.base.Entity>`, this mapper will fetch an :class:`AttributeMapper` for each one. Lookups will return the value from the first :class:`AttributeMapper` which has an entry for a given key. Assignments will be made to the first :class:`.Entity` in the iterable.
+       
+       :param entities: An iterable of :class:`.Entity` subclass instances.
+       
+       """
        def __init__(self, entities):
                self._attributes = [e.attributes for e in entities]
                super(PassthroughAttributeMapper, self).__init__(self._attributes[0].entity)
index 28740fd..d3054b9 100644 (file)
@@ -8,6 +8,17 @@ from philo.exceptions import MIDDLEWARE_NOT_CONFIGURED
 
 @vary_on_headers('Accept')
 def node_view(request, path=None, **kwargs):
+       """
+       :func:`node_view` handles incoming requests by checking to make sure that:
+       
+       - the request has an attached :class:`.Node`.
+       - the attached :class:`~philo.models.nodes.Node` handles any remaining path beyond its location.
+       
+       If these conditions are not met, then :func:`node_view` will either raise :exc:`Http404` or, if it seems like the address was mistyped (for example missing a trailing slash), return an :class:`HttpResponseRedirect` to the correct address.
+       
+       Otherwise, :func:`node_view` will call the :class:`.Node`'s :meth:`~.Node.render_to_response` method, passing ``kwargs`` in as the ``extra_context``.
+       
+       """
        if "philo.middleware.RequestNodeMiddleware" not in settings.MIDDLEWARE_CLASSES:
                raise MIDDLEWARE_NOT_CONFIGURED