diff --git a/docs/topics/http/_images/middleware.graffle b/docs/topics/http/_images/middleware.graffle new file mode 100644 index 0000000000..4aa85f7611 --- /dev/null +++ b/docs/topics/http/_images/middleware.graffle @@ -0,0 +1,957 @@ + + + + + ActiveLayerIndex + 0 + ApplicationVersion + + com.omnigroup.OmniGrafflePro + 139.16.0.171715 + + AutoAdjust + + BackgroundGraphic + + Bounds + {{0, 0}, {559.28997802734375, 782.8900146484375}} + Class + SolidGraphic + ID + 2 + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + BaseZoom + 0 + CanvasOrigin + {0, 0} + ColumnAlign + 1 + ColumnSpacing + 36 + CreationDate + 2012-12-09 18:55:12 +0000 + Creator + Aymeric Augustin + DisplayScale + 1.000 cm = 1.000 cm + GraphDocumentVersion + 8 + GraphicsList + + + Bounds + {{144, 405}, {369, 27}} + Class + ShapedGraphic + ID + 33 + Shape + Bezier + ShapeData + + UnitPoints + + {-0.5, -0.5} + {-0.5, -0.5} + {0.47959183673469341, -0.5} + {0.47959183673469408, -0.5} + {0.47959183673469341, -0.5} + {0.5, 0} + {0.5, 0} + {0.5, 0} + {0.47959183673469408, 0.5} + {0.47959183673469408, 0.5} + {0.47959183673469408, 0.5} + {-0.5, 0.5} + {-0.5, 0.5} + {-0.5, 0.5} + {-0.47560975609756084, 0} + {-0.47560975609756084, 0} + {-0.47560975609756084, 0} + {-0.5, -0.5} + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 view function} + + + + Bounds + {{229.5, 238.5}, {297, 36}} + Class + ShapedGraphic + ID + 31 + Rotation + 270 + Shape + AdjustableArrow + ShapeData + + width + 27 + + Style + + fill + + Color + + a + 0.8 + b + 1 + g + 1 + r + 1 + + MiddleFraction + 0.70634919404983521 + + shadow + + Color + + a + 0.4 + b + 0 + g + 0 + r + 0 + + Draws + NO + Fuzziness + 0.0 + ShadowVector + {0, 2} + + stroke + + Color + + b + 0 + g + 0 + r + 1 + + Pattern + 1 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;\red255\green0\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf2 process_exception} + + TextRelativeArea + {{0.125, 0.25}, {0.75, 0.5}} + isConnectedShape + + + + Bounds + {{328.5, 229.5}, {315, 36}} + Class + ShapedGraphic + ID + 30 + Rotation + 270 + Shape + AdjustableArrow + ShapeData + + width + 27 + + Style + + fill + + Color + + a + 0.8 + b + 1 + g + 1 + r + 1 + + MiddleFraction + 0.70634919404983521 + + shadow + + Color + + a + 0.4 + b + 0 + g + 0 + r + 0 + + Draws + NO + Fuzziness + 0.0 + ShadowVector + {0, 2} + + stroke + + Color + + b + 0 + g + 0.501961 + r + 0 + + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;\red0\green128\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf2 process_response} + + TextRelativeArea + {{0.125, 0.25}, {0.75, 0.5}} + isConnectedShape + + + + Bounds + {{283.5, 238.5}, {297, 36}} + Class + ShapedGraphic + ID + 29 + Rotation + 270 + Shape + AdjustableArrow + ShapeData + + width + 27 + + Style + + fill + + Color + + a + 0.8 + b + 1 + g + 1 + r + 1 + + MiddleFraction + 0.70634919404983521 + + shadow + + Color + + a + 0.4 + b + 0 + g + 0 + r + 0 + + Draws + NO + Fuzziness + 0.0 + ShadowVector + {0, 2} + + stroke + + Color + + b + 0 + g + 0.501961 + r + 0 + + Pattern + 1 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;\red0\green128\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf2 process_template_response} + + TextRelativeArea + {{0.125, 0.25}, {0.75, 0.5}} + isConnectedShape + + + + Bounds + {{27, 243}, {288, 36}} + Class + ShapedGraphic + ID + 28 + Rotation + 90 + Shape + AdjustableArrow + ShapeData + + width + 27 + + Style + + fill + + Color + + a + 0.8 + b + 1 + g + 1 + r + 1 + + MiddleFraction + 0.70634919404983521 + + shadow + + Color + + a + 0.4 + b + 0 + g + 0 + r + 0 + + Draws + NO + Fuzziness + 0.0 + ShadowVector + {0, 2} + + stroke + + Color + + b + 0 + g + 0.501961 + r + 0 + + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;\red0\green128\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf2 process_view} + + TextRelativeArea + {{0.125, 0.25}, {0.75, 0.5}} + isConnectedShape + + + + Bounds + {{-40.500000000767386, 220.49999999804004}, {297, 36}} + Class + ShapedGraphic + ID + 27 + Rotation + 90 + Shape + AdjustableArrow + ShapeData + + width + 27 + + Style + + fill + + Color + + a + 0.8 + b + 1 + g + 1 + r + 1 + + MiddleFraction + 0.70634919404983521 + + shadow + + Color + + a + 0.4 + b + 0 + g + 0 + r + 0 + + Draws + NO + Fuzziness + 0.0 + ShadowVector + {0, 2} + + stroke + + Color + + b + 0 + g + 0.501961 + r + 0 + + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;\red0\green128\blue0;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf2 process_request} + + TextRelativeArea + {{0.125, 0.25}, {0.75, 0.5}} + isConnectedShape + + + + Bounds + {{360, 63}, {144, 27}} + Class + ShapedGraphic + ID + 12 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 HttpResponse} + + + + Bounds + {{72, 63}, {144, 27}} + Class + ShapedGraphic + ID + 11 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 HttpRequest} + + + + Bounds + {{72, 324}, {432, 27}} + Class + ShapedGraphic + ID + 10 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Style + + fill + + FillType + 2 + GradientAngle + 90 + GradientColor + + w + 0.666667 + + + stroke + + CornerRadius + 5 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 MessageMiddleware} + + + + Bounds + {{72, 279}, {432, 27}} + Class + ShapedGraphic + ID + 9 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Style + + fill + + FillType + 2 + GradientAngle + 90 + GradientColor + + w + 0.666667 + + + stroke + + CornerRadius + 5 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 AuthenticationMiddleware} + + + + Bounds + {{72, 234}, {432, 27}} + Class + ShapedGraphic + ID + 8 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Style + + fill + + FillType + 2 + GradientAngle + 90 + GradientColor + + w + 0.666667 + + + stroke + + CornerRadius + 5 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 CsrfViewMiddleware} + + + + Bounds + {{72, 189}, {432, 27}} + Class + ShapedGraphic + ID + 7 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Style + + fill + + FillType + 2 + GradientAngle + 90 + GradientColor + + w + 0.666667 + + + stroke + + CornerRadius + 5 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 SessionMiddleware} + + + + Bounds + {{72, 144}, {432, 27}} + Class + ShapedGraphic + ID + 6 + Magnets + + {0, 1} + {0, -1} + {1, 0} + {-1, 0} + + Shape + Rectangle + Style + + fill + + FillType + 2 + GradientAngle + 90 + GradientColor + + w + 0.666667 + + + stroke + + CornerRadius + 5 + + + Text + + Text + {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340 +\cocoascreenfonts1{\fonttbl\f0\fmodern\fcharset0 Courier;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc + +\f0\fs24 \cf0 CommonMiddleware} + + + + GridInfo + + ShowsGrid + YES + SnapsToGrid + YES + + GuidesLocked + NO + GuidesVisible + YES + HPages + 1 + ImageCounter + 1 + KeepToScale + + Layers + + + Lock + NO + Name + Calque 1 + Print + YES + View + YES + + + LayoutInfo + + Animate + NO + circoMinDist + 18 + circoSeparation + 0.0 + layoutEngine + dot + neatoSeparation + 0.0 + twopiSeparation + 0.0 + + LinksVisible + NO + MagnetsVisible + NO + MasterSheets + + ModificationDate + 2012-12-09 19:48:54 +0000 + Modifier + Aymeric Augustin + NotesVisible + NO + Orientation + 2 + OriginVisible + NO + PageBreaks + YES + PrintInfo + + NSBottomMargin + + float + 41 + + NSHorizonalPagination + + coded + BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG + + NSLeftMargin + + float + 18 + + NSPaperSize + + size + {595.28997802734375, 841.8900146484375} + + NSPrintReverseOrientation + + int + 0 + + NSRightMargin + + float + 18 + + NSTopMargin + + float + 18 + + + PrintOnePage + + ReadOnly + NO + RowAlign + 1 + RowSpacing + 36 + SheetTitle + Canevas 1 + SmartAlignmentGuidesActive + YES + SmartDistanceGuidesActive + YES + UniqueID + 1 + UseEntirePage + + VPages + 1 + WindowInfo + + CurrentSheet + 0 + ExpandedCanvases + + Frame + {{248, 4}, {694, 874}} + ListView + + OutlineWidth + 142 + RightSidebar + + ShowRuler + + Sidebar + + SidebarWidth + 120 + VisibleRegion + {{0, 0}, {559, 735}} + Zoom + 1 + ZoomValues + + + Canevas 1 + 1 + 1 + + + + + diff --git a/docs/topics/http/_images/middleware.png b/docs/topics/http/_images/middleware.png deleted file mode 100644 index 505c70ac36..0000000000 Binary files a/docs/topics/http/_images/middleware.png and /dev/null differ diff --git a/docs/topics/http/_images/middleware.svg b/docs/topics/http/_images/middleware.svg new file mode 100644 index 0000000000..4da8d22da8 --- /dev/null +++ b/docs/topics/http/_images/middleware.svg @@ -0,0 +1,3 @@ + + +2012-12-09 19:48ZCanevas 1Calque 1CommonMiddlewareSessionMiddlewareCsrfViewMiddlewareAuthenticationMiddlewareMessageMiddlewareHttpRequestHttpResponseprocess_requestprocess_viewprocess_template_responseprocess_responseprocess_exceptionview function diff --git a/docs/topics/http/middleware.txt b/docs/topics/http/middleware.txt index c27e7e8690..97d4a07784 100644 --- a/docs/topics/http/middleware.txt +++ b/docs/topics/http/middleware.txt @@ -32,17 +32,20 @@ created by :djadmin:`django-admin.py startproject `:: 'django.contrib.messages.middleware.MessageMiddleware', ) -During the request phases (:meth:`process_request` and :meth:`process_view` -middleware), Django applies middleware in the order it's defined in +During the request phases (:meth:`process_request` and :meth:`process_view`), +Django applies middleware in the order it's defined in :setting:`MIDDLEWARE_CLASSES`, top-down. During the response phases -(:meth:`process_response` and :meth:`process_exception` middleware), the -classes are applied in reverse order, from the bottom up. You can think of it -like an onion: each middleware class is a "layer" that wraps the view: +(:meth:`process_template_response`, :meth:`process_response`, and +:meth:`process_exception`), the classes are applied in reverse order, from the +bottom up. -.. image:: _images/middleware.png - :width: 502 - :height: 417 - :alt: Middleware application order. +.. image:: _images/middleware.svg + :alt: middleware application order + :width: 480 + :height: 408 + +If you prefer, you can also think of it like an onion: each middleware class +is a "layer" that wraps the view. A Django installation doesn't require any middleware -- e.g., :setting:`MIDDLEWARE_CLASSES` can be empty, if you'd like -- but it's strongly