From c1dc1860da86dc119f2e80837c6b327af12b9b38 Mon Sep 17 00:00:00 2001 From: Mike TUMS Date: Mon, 28 Jan 2013 00:32:32 +0400 Subject: [PATCH] Update docs/tutorial/1-serialization.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update for tutorials (manual serialization) to support HTTP PATCH method (partial update of instance) --- docs/tutorial/1-serialization.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md index f5ff167f0..d66d2b97c 100644 --- a/docs/tutorial/1-serialization.md +++ b/docs/tutorial/1-serialization.md @@ -129,12 +129,12 @@ The first thing we need to get started on our Web API is provide a way of serial Create or update a new snippet instance. """ if instance: - # Update existing instance - instance.title = attrs['title'] - instance.code = attrs['code'] - instance.linenos = attrs['linenos'] - instance.language = attrs['language'] - instance.style = attrs['style'] + # Update existing instance or part of it + instance.title = attrs.get('title', instance.title) + instance.code = attrs.get('code', instance.code) + instance.linenos = attrs.get('linenos', instance.linenos) + instance.language = attrs.get('language', instance.language) + instance.style = attrs.get('style', instance.style) return instance # Create new instance