From 01af969bfa26996e76830b7a718f4a56a4f64341 Mon Sep 17 00:00:00 2001 From: Tobias Sauerwein Date: Wed, 25 Jun 2014 16:07:37 +0200 Subject: [PATCH 1/2] Update custom widget example in docs The example for a custom widget in the docs builds an input field like this: return u'' % quoted But the `name` property is not set, so no data would be submitted for this field. (cherry picked from commit 524347e197df2b1f9258edcc55fcdba724051bf1) --- docs/widget.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/widget.rst b/docs/widget.rst index dc27e97f..7687413e 100644 --- a/docs/widget.rst +++ b/docs/widget.rst @@ -379,7 +379,8 @@ get defined as so: if cstruct is null: cstruct = u'' quoted = cgi.escape(cstruct, quote='"') - return u'' % quoted + return ('' % + (field.name, quoted)) Note that every ``serialize`` method is responsible for returning a serialization, no matter whether it is provided data by its caller or @@ -451,7 +452,8 @@ attached. def serialize(self, field, cstruct, readonly=False): if cstruct is null: cstruct = u'' - return '' % cgi.escape(cstruct) + return ('' % + (field.name, cgi.escape(cstruct, quote='"'))) def deserialize(self, field, pstruct): if pstruct is null: @@ -494,7 +496,8 @@ class: def serialize(self, field, cstruct, readonly=False): if cstruct is null: cstruct = u'' - return '' % cgi.escape(cstruct) + return ('' % + (field.name, cgi.escape(cstruct, quote='"'))) def deserialize(self, field, pstruct): if pstruct is null: From 60c79edab8c30452801980401fc5685d59c4cfbd Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 23 Aug 2020 02:55:11 -0700 Subject: [PATCH 2/2] Update widget docs per #226 for consistency across code examples (cherry picked from commit b7442ed3cf2d3a1d9e68dcb2d98638a4fb9f4eee) --- docs/widget.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/widget.rst b/docs/widget.rst index 7687413e..d4b64364 100644 --- a/docs/widget.rst +++ b/docs/widget.rst @@ -452,8 +452,9 @@ attached. def serialize(self, field, cstruct, readonly=False): if cstruct is null: cstruct = u'' + quoted = cgi.escape(cstruct, quote='"') return ('' % - (field.name, cgi.escape(cstruct, quote='"'))) + (field.name, quoted)) def deserialize(self, field, pstruct): if pstruct is null: @@ -496,8 +497,9 @@ class: def serialize(self, field, cstruct, readonly=False): if cstruct is null: cstruct = u'' + quoted = cgi.escape(cstruct, quote='"') return ('' % - (field.name, cgi.escape(cstruct, quote='"'))) + (field.name, quoted)) def deserialize(self, field, pstruct): if pstruct is null: