Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created February 23, 2013 17:39
Show Gist options
  • Save jacobian/5020615 to your computer and use it in GitHub Desktop.
Save jacobian/5020615 to your computer and use it in GitHub Desktop.
digraph CreateView {
// Basic graph, node, and edge styling.
splines="true";
ranksep=0.4;
node [shape="box", style="rounded" fontsize="9", height="0.3", fontname="Open Sans Light"];
edge [headport="n"];
// Graph title - \G means "title of the graph"; the \ns are the only way
// I can find to visuall separate the title from the rest of the graph.
label="\G\n\n";
labelloc="t";
fontname="Open Sans Bold";
fontsize=16;
// Styling and labels for the "links" (visually, not really) to the the "get
// form" and "render page" subgraphs. There are essentially "fake" nodes
// (formflow_get, renderflow_post, etc) which serve as terminal points
// visually; the actual subflows themselves then get stacked side by side.
subgraph subflows {
node [style="dashed", shape="circle", fontname="Open Sans Light Italic", width=0.6, fixedsize=true];
formflow_get [label="get\nform"];
formflow_post [label="get\nform"];
formflow [label="get\nform"];
renderflow_get [label="render\npage"];
renderflow_post [label="render\npage"];
renderflow [label="render\npage"];
}
// The "main" flow - method, get/post, form handling.
subgraph main {
// dispatch -> Http method?
dispatch -> ifmethod;
dispatch [style="bold"];
ifmethod [label="Http\nmethod?", shape="diamond", style=""]
// method not allowed
ifmethod -> http_method_not_allowed [color="grey"];
http_method_not_allowed [color="grey", fontcolor="grey"];
// get flow: get the form, render the page
ifmethod -> get;
get:s -> formflow_get;
get:s -> renderflow_get;
// post flow: get form; if valid: form_valid; if invalid: render page
ifmethod -> post;
post:s -> formflow_post;
post:s -> ifvalid
ifvalid -> form_valid;
form_valid -> get_success_url;
ifvalid -> form_invalid;
form_invalid -> renderflow_post;
ifvalid [label="form\nvalid?", shape="diamond", style=""]
// put/post handling
ifmethod -> put [color="grey"];
put [color="grey", fontcolor="grey"];
put:w -> post:e [constraint=false, color="grey"];
}
// the "get the form" flow
subgraph formflow {
edge [tailport="s"];
formflow -> get_form_class;
get_form_class -> get_queryset;
formflow -> get_form;
get_form -> get_form_kwargs;
get_form_kwargs -> get_initial;
}
// the "render the page" flow
subgraph renderflow {
edge [tailport="s"];
renderflow -> get_context_data;
get_context_data -> get_context_object_name;
renderflow -> render_to_response;
render_to_response -> get_template_names;
}
}
digraph ListView {
// Basic graph, node, and edge styling.
rankdir="LR";
splines="true";
concentrate=true;
ranksep=0.6;
node [shape="box", style="rounded" fontsize="9", height="0.3", fontname="Open Sans Light"];
edge [headport="w", tailport="e"];
// Graph title - \G means "title of the graph"; the \ns are the only way
// I can find to visuall separate the title from the rest of the graph.
label="\G\n\n";
labelloc="t";
fontname="Open Sans Bold";
fontsize=16;
// dispatch -> Http method?
dispatch -> ifmethod;
dispatch [style="bold"];
ifmethod [label="Http\nmethod?", shape="diamond", style=""]
// method not allowed
subgraph not_allowed {
node [color="grey", fontcolor="grey"];
rank=same;
ifmethod:s -> http_method_not_allowed:n [color="grey"];
}
ifmethod -> get;
get -> get_queryset;
get -> get_allow_empty;
get -> get_context_data;
get_context_data -> get_paginate_by;
get_context_data -> get_context_object_name;
get_context_data -> paginate_queryset;
paginate_queryset -> get_paginator;
get -> render_to_response;
render_to_response -> get_template_names;
}
digraph RedirectView {
// Basic graph options
rankdir="LR";
splines="true";
concentrate="true";
ranksep="0.6";
// Graph title - \G means "title of the graph"; the \ns are the only way
// I can find to visuall separate the title from the rest of the graph.
label="\G\n\n";
labelloc="t";
fontname="Open Sans Bold";
fontsize=16;
node [shape="box", style="rounded" fontsize="9", height="0.3", fontname="Open Sans Light"];
// Control the grouping of the not-allowed / other methods nodes.
// This is a bit hackish, but it makes them show up in the same rank (column)
// which is most readable. This has to come before dispatch so that the
// order works out correctly.
http_method_not_allowed; ifmethod; other;
subgraph httpmethods {
rank="same";
ifmethod -> http_method_not_allowed [constraint="false", color="grey"];
ifmethod -> other [color="grey"];
other [label="delete, head,\noptions, post, put", color="grey", fontcolor="grey"];
http_method_not_allowed [color="grey", fontcolor="grey"];
}
other:e -> get:s [constraint="false", color="grey"];
// dispatch -> Http method?
dispatch -> ifmethod;
dispatch [style="bold"];
ifmethod [label="Http\nmethod?", shape="diamond", style=""];
// get
ifmethod -> get;
get -> get_redirect_url;
}
digraph TemplateView {
// Basic graph options
rankdir="LR";
splines="true";
concentrate="true";
ranksep="0.6";
// Graph title - \G means "title of the graph"; the \ns are the only way
// I can find to visuall separate the title from the rest of the graph.
label="\G\n\n";
labelloc="t";
fontname="Open Sans Bold";
fontsize=16;
node [shape="box", style="rounded" fontsize="9", height="0.3", fontname="Open Sans Light"];
// dispatch -> Http method?
dispatch -> ifmethod;
dispatch [style="bold"];
ifmethod [label="Http\nmethod?", shape="diamond", style=""];
// get
ifmethod -> get;
get -> get_context_data;
get -> render_to_response;
render_to_response -> get_template_names
// method not allowed
subgraph not_allowed {
rank=same;
ifmethod -> http_method_not_allowed [color="grey"];
http_method_not_allowed [color="grey", fontcolor="grey"];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment